network

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MarshalError = 0
	NetError     = 1
)
View Source
const (
	//MsgHeaderLength Tcp消息头长度
	MsgHeaderLength = 8
	//MsgSizeLength 整个包体长度
	MsgSizeLength = 4
	//MaxConnection 最大链接接受数
	MaxConnection = 1000

	ConnectEventID    = 1
	DisconnectEventID = 2
)

Variables

This section is empty.

Functions

func BytesToInt

func BytesToInt(b []byte) int

BytesToInt 字节转换成整形

func Init_TcpClient

func Init_TcpClient(handler msghandler, connCallBack connectEvent, ip, port string)

func IntToBytes

func IntToBytes(n int) []byte

IntToBytes 整形转换成字节

Types

type Client

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

ConnInfo Tcp链接

var (
	ClientConn *Client
)

func (*Client) SendMsgToServer

func (this *Client) SendMsgToServer(data []byte, msgtype int) bool

func (*Client) SendPBToServer

func (m *Client) SendPBToServer(pb proto.Message, mygtype int) (bool, error)

type ConnInfo

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

type SendError

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

func (SendError) Error

func (cerr SendError) Error() string

type SendErrorType

type SendErrorType uint8

type Server

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

func (*Server) Init_TcpServer

func (this *Server) Init_TcpServer(hand msghandler, connEvent connectEvent, port string)

func (*Server) SendMsg

func (this *Server) SendMsg(msg []byte, msgtype, connId int)

Jump to

Keyboard shortcuts

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