tcpserver

package
v0.0.55 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PacketSizeLimit uint64
	ReadBufferSize  int
}

type Connection added in v0.0.37

type Connection struct {
	Conn        net.Conn
	CloseReason string
}

func (*Connection) DisconnectFromServer added in v0.0.37

func (o *Connection) DisconnectFromServer(reason string)

type OnConnctedFuncType

type OnConnctedFuncType func(conn net.Conn) error

type OnDisconnctedFuncType

type OnDisconnctedFuncType func(conn net.Conn, closeReason string)

type OnReceiveFuncType

type OnReceiveFuncType func(conn net.Conn, data []byte) ([]byte, error)

type TcpServer

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

func NewTcpServer

func NewTcpServer(config *Config,
	onConnctedFunc OnConnctedFuncType,
	onDisconnctedFunc OnDisconnctedFuncType,
	onReceiveFunc OnReceiveFuncType) *TcpServer

func (*TcpServer) DisconnectConnection added in v0.0.37

func (o *TcpServer) DisconnectConnection(conn net.Conn, reason string)

func (*TcpServer) SendToUser added in v0.0.16

func (o *TcpServer) SendToUser(conn net.Conn, data []byte) error

func (*TcpServer) Start

func (o *TcpServer) Start(address string) error

func (*TcpServer) Stop

func (o *TcpServer) Stop(ctx context.Context) error

stop accept new connection, and close all connection read stream wait all connection current handle finished

Jump to

Keyboard shortcuts

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