tcp

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TTCPClient

type TTCPClient struct {
	AutoReconnect bool

	OnRun        func(*conn.TConnection) //
	OnRead       func(*conn.TData)       // 读取回调
	OnConnect    func(*conn.TConnection) // 连接成功
	OnDisconnect func(*conn.TConnection) // 断开成功
	// contains filtered or unexported fields
}

TTCPClient TCP连接客户端

func NewTCPClient

func NewTCPClient() *TTCPClient

NewTCPClient 新建

func (*TTCPClient) Close

func (self *TTCPClient) Close()

Close 关闭连接

func (*TTCPClient) Connect

func (self *TTCPClient) Connect(strAddress string)

Connect 连接服务器

func (*TTCPClient) Write

func (self *TTCPClient) Write(buff []byte) (int, error)

Write 发送包

func (*TTCPClient) WritePack

func (self *TTCPClient) WritePack(buff []byte) (int, error)

WritePack 发送封包, 并且自动粘头

type TTCPServer

type TTCPServer struct {
	MaxConnNum int

	OnRun              func(*conn.TConnection) // 自处理循环回调
	OnRead             func(*conn.TData)       // 读取回调(buf, 包长, sessionid)
	OnClientConnect    func(*conn.TConnection) // 客户端连接上来了
	OnClientDisconnect func(*conn.TConnection) // 客户端断开了
	// contains filtered or unexported fields
}

TTCPServer 服务器类

func NewTCPServer

func NewTCPServer() *TTCPServer

NewTCPServer 新建

func (*TTCPServer) Start

func (self *TTCPServer) Start(strAddress string)

Start 启动服务器

func (*TTCPServer) Stop

func (self *TTCPServer) Stop()

Stop 停服

Jump to

Keyboard shortcuts

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