Documentation ¶
Overview ¶
Package tcp TCP 服务器
Index ¶
- func NewServer(onHander network.MessageHander, sessionManager network.SessionManager, ...) network.Peer
- type Config
- type Option
- func WithCloseTimeout(closeTimeout time.Duration) Option
- func WithDatapack(datapack network.Datapack) Option
- func WithHost(host string) Option
- func WithIPVersion(ipVersion string) Option
- func WithLogger(logger logger.Logger) Option
- func WithMaxConnNum(maxConnNum int) Option
- func WithName(name string) Option
- func WithOnConnClose(onConnClose network.ConnFunc) Option
- func WithOnConnected(onConnected network.ConnFunc) Option
- func WithOnServerStart(onServerStart network.ServerFunc) Option
- func WithPort(port int) Option
- func WithRecvBufferSize(recvBufferSize int) Option
- func WithRecvDeadLine(recvDeadLine time.Duration) Option
- func WithRecvQueueSize(recvQueueSize int) Option
- func WithSendBufferSize(sendBufferSize int) Option
- func WithSendDeadLine(sendDeadLine time.Duration) Option
- func WithSendQueueSize(sendQueueSize int) Option
- func WithWhetherCloseConnWhenFailed(isForceClose bool) Option
- func WithonServerClose(onServerClose network.ServerFunc) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServer ¶
func NewServer(onHander network.MessageHander, sessionManager network.SessionManager, opts ...Option) network.Peer
NewServer 创建一个 tcp 服务器
Types ¶
type Option ¶
type Option func(*server)
Option ..
func WithCloseTimeout ¶
WithCloseTimeout 设置服务名称
func WithIPVersion ¶
WithIPVersion 设置 IP 版本 ipVersion: "tcp", "tcp4", "tcp6"
func WithOnConnClose ¶
WithOnConnClose 客户端连接关闭
func WithOnConnected ¶
WithOnConnected 客户端连接到来
func WithOnServerStart ¶
func WithOnServerStart(onServerStart network.ServerFunc) Option
WithOnServerStart 服务器启动时触发,此时尚未有客户端连进来
func WithRecvBufferSize ¶
WithRecvBufferSize 设置连接数量上限
func WithRecvDeadLine ¶
WithRecvDeadLine 设置连接数量上限
func WithRecvQueueSize ¶
WithRecvQueueSize 接收到的消息队列大小,接收到的消息由 Session 放到 Peer 的队列中,异步处理
func WithSendBufferSize ¶
WithSendBufferSize 设置连接数量上限
func WithSendDeadLine ¶
WithSendDeadLine 设置连接数量上限
func WithSendQueueSize ¶
WithSendQueueSize 发送的消息队列大小,消息优先发送到消息队列,然后写入到套接字中
func WithWhetherCloseConnWhenFailed ¶
WithWhetherCloseConnWhenFailed 当错误发生时,是否关闭连接
func WithonServerClose ¶
func WithonServerClose(onServerClose network.ServerFunc) Option
WithonServerClose 服务端关闭时触发,此时尚已关闭客户端连接
Click to show internal directories.
Click to hide internal directories.