Help us shape the future of Go! Take the 2026 Go Developer Survey

tcp

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 8 Imported by: 1

README

tcp

tcp server/client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallBack

type CallBack interface {
	OnConnected(conn *TCPConnection)
	OnMessage(conn *TCPConnection, p Packet)
	OnDisconnected(conn *TCPConnection)
	OnError(err error)
}

type ConnBucket

type ConnBucket struct {
	// contains filtered or unexported fields
}

func NewConnBucket

func NewConnBucket() *ConnBucket

func (*ConnBucket) Delete

func (b *ConnBucket) Delete(id string)

func (*ConnBucket) Get

func (b *ConnBucket) Get(id string) *TCPConnection

func (*ConnBucket) GetAll

func (b *ConnBucket) GetAll() map[string]*TCPConnection

func (*ConnBucket) Put

func (b *ConnBucket) Put(id string, c *TCPConnection)

type Packet

type Packet interface {
	Bytes() []byte
}

type Protocol

type Protocol interface {
	ReadPacket(reader io.Reader) (Packet, error)
	WritePacket(writer io.Writer, msg Packet) error
}

type TCPConnection

type TCPConnection struct {
	// contains filtered or unexported fields
}

func NewTCPConnection

func NewTCPConnection(conn *net.TCPConn, callback CallBack, protocol Protocol) *TCPConnection

func (*TCPConnection) Close

func (c *TCPConnection) Close(flag int)

func (*TCPConnection) GetLocalAddr

func (c *TCPConnection) GetLocalAddr() net.Addr

func (*TCPConnection) GetLocalIPAddress

func (c *TCPConnection) GetLocalIPAddress() string

func (*TCPConnection) GetRawConn

func (c *TCPConnection) GetRawConn() *net.TCPConn

func (*TCPConnection) GetRemoteAddr

func (c *TCPConnection) GetRemoteAddr() net.Addr

func (*TCPConnection) GetRemoteIPAddress

func (c *TCPConnection) GetRemoteIPAddress() string

func (*TCPConnection) IsClosed

func (c *TCPConnection) IsClosed() bool

func (*TCPConnection) ReadPacket

func (c *TCPConnection) ReadPacket() (Packet, error)

func (*TCPConnection) Serve

func (c *TCPConnection) Serve() error

func (*TCPConnection) WritePacket

func (c *TCPConnection) WritePacket(p Packet) error

type TCPServer

type TCPServer struct {
	// contains filtered or unexported fields
}

func NewTCPServer

func NewTCPServer(addr string, callback CallBack, protocol Protocol) *TCPServer

func (*TCPServer) Close

func (srv *TCPServer) Close()

func (*TCPServer) Connect

func (srv *TCPServer) Connect(ip string, callback CallBack, protocol Protocol) (*TCPConnection, error)

func (*TCPServer) GetAllTCPConn

func (srv *TCPServer) GetAllTCPConn() []*TCPConnection

func (*TCPServer) GetTCPConn

func (srv *TCPServer) GetTCPConn(key string) *TCPConnection

func (*TCPServer) ListenAndServe

func (srv *TCPServer) ListenAndServe() error

func (*TCPServer) Serve

func (srv *TCPServer) Serve(l *net.TCPListener) error

func (*TCPServer) SetReadTimeOut

func (srv *TCPServer) SetReadTimeOut(t time.Duration)

func (*TCPServer) SetWriteTimeOut

func (srv *TCPServer) SetWriteTimeOut(t time.Duration)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL