Documentation ¶
Index ¶
- func BitToMask(bit int) string
- func GetFreeTCPPort() (int, error)
- func GetFreeUDPPort() (int, error)
- func GetIPV4Address() []string
- func GetIPV6Address(global bool) []string
- func GetNetTCPListener(addr string, dupFd uintptr) (*net.TCPListener, error)
- func IP4ToInt(str string) uint32
- func InetAton(ipnr string) int64
- func InetNtoa(ipnr int64) net.IP
- func IsPublicIP(IP net.IP) bool
- func MaskToBit(str string) int
- type ConnEx
- func (me *ConnEx) AppendHeaderBuffer(buf []byte)
- func (me *ConnEx) CheckBuffer(maxBuf int)
- func (me *ConnEx) Close()
- func (me *ConnEx) Connect() (bool, error)
- func (me *ConnEx) ConnectTLS() (bool, error)
- func (me *ConnEx) GetData() []byte
- func (me *ConnEx) GetDataBuffer() *bytes.Buffer
- func (me *ConnEx) GetDataLen() int
- func (me *ConnEx) GetFd() uintptr
- func (me *ConnEx) GetHeaderBuffer() []byte
- func (me *ConnEx) GetHeaderLen() int
- func (me *ConnEx) GetHeaderLength() int
- func (me *ConnEx) GetHeaderMsg() interface{}
- func (me *ConnEx) GetHost() string
- func (me *ConnEx) GetIf() ConnExIf
- func (me *ConnEx) GetLastRecvPacket() int64
- func (me *ConnEx) GetLastUpdate() int64
- func (me *ConnEx) GetPktNum() int64
- func (me *ConnEx) GetRecvTimeout() int
- func (me *ConnEx) Init()
- func (me *ConnEx) IsConnected() bool
- func (me *ConnEx) ReadEx() (int, error, bool)
- func (me *ConnEx) ReadExBuffer(inBuf []byte, retLen *int) (int, error, bool)
- func (me *ConnEx) ReadLen(len int) (int, error)
- func (me *ConnEx) Reset()
- func (me *ConnEx) SendDequeue() []byte
- func (me *ConnEx) SendEnqueue(data []byte)
- func (me *ConnEx) SetConn(conn net.Conn)
- func (me *ConnEx) SetConnTimeout(ms int)
- func (me *ConnEx) SetHeaderLen(len int)
- func (me *ConnEx) SetHost(host string)
- func (me *ConnEx) SetIf(connIf ConnExIf)
- func (me *ConnEx) SetMaxDataLen(v int)
- func (me *ConnEx) SetReadBuffer(size int)
- func (me *ConnEx) SetRecvTimeout(ms int)
- func (me *ConnEx) SetSendTimeout(ms int)
- func (me *ConnEx) SetWriteBuffer(size int)
- type ConnExIf
- type ConnExIfImp
- type DefaultMsgHeader
- type MacIP
- type MyServer
- func (me *MyServer) GetClient() xmap.Map[int64, *MySrvClient]
- func (me *MyServer) GetClientById(id int64) *MySrvClient
- func (me *MyServer) GetClientCount() int
- func (me *MyServer) GetUserData() interface{}
- func (me *MyServer) ParseHeader(b []byte) (int, interface{})
- func (me *MyServer) SetInterface(srvInf MySrvInf)
- func (me *MyServer) SetSendBuffer(size int64)
- func (me *MyServer) SetUserData(data interface{})
- func (me *MyServer) Start() (bool, error)
- func (me *MyServer) Stop()
- type MySrvClient
- func (me *MySrvClient) EnableKeepAlive(interval, count int) error
- func (me *MySrvClient) ForceClose(arg ...int)
- func (me *MySrvClient) GetClientID() int64
- func (me *MySrvClient) GetCloseError() string
- func (me *MySrvClient) GetConn() *ConnEx
- func (me *MySrvClient) GetCreateTime() int64
- func (me *MySrvClient) GetDefaultHeader() *DefaultMsgHeader
- func (me *MySrvClient) GetIP() string
- func (me *MySrvClient) GetRemoteAddressString() string
- func (me *MySrvClient) GetSendQueueLen() int
- func (me *MySrvClient) GetUserData() interface{}
- func (me *MySrvClient) IsClose() bool
- func (me *MySrvClient) Send(data []byte, copy ...bool) bool
- func (me *MySrvClient) SendDequeue() *sendQueue
- func (me *MySrvClient) SendNoHeader(msgType int32, data []byte, dataLen int) bool
- func (me *MySrvClient) SetUserData(data interface{})
- func (me *MySrvClient) Write(p []byte) (int, error)
- type MySrvInf
- type MySrvInfImp
- type NetExHeaderMsg
- type TLSConfig
- type TcpListenerEx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFreeTCPPort ¶
func GetFreeUDPPort ¶
func GetIPV4Address ¶
func GetIPV4Address() []string
func GetIPV6Address ¶
func GetNetTCPListener ¶
func GetNetTCPListener(addr string, dupFd uintptr) (*net.TCPListener, error)
func IsPublicIP ¶
Types ¶
type ConnEx ¶
func NewTLSTcpClient ¶
func NewUnixClient ¶
func (*ConnEx) AppendHeaderBuffer ¶
func (*ConnEx) CheckBuffer ¶
func (*ConnEx) ConnectTLS ¶
func (*ConnEx) GetDataBuffer ¶
func (*ConnEx) GetDataLen ¶
func (*ConnEx) GetHeaderBuffer ¶
func (*ConnEx) GetHeaderLen ¶
func (*ConnEx) GetHeaderLength ¶
func (*ConnEx) GetHeaderMsg ¶
func (me *ConnEx) GetHeaderMsg() interface{}
func (*ConnEx) GetLastRecvPacket ¶
func (*ConnEx) GetLastUpdate ¶
func (*ConnEx) GetRecvTimeout ¶
func (*ConnEx) IsConnected ¶
func (*ConnEx) ReadExBuffer ¶
ReadExBuffer return ok, error, timeout
func (*ConnEx) SendDequeue ¶
func (*ConnEx) SendEnqueue ¶
func (*ConnEx) SetConnTimeout ¶
func (*ConnEx) SetHeaderLen ¶
func (*ConnEx) SetMaxDataLen ¶
func (*ConnEx) SetReadBuffer ¶
func (*ConnEx) SetRecvTimeout ¶
func (*ConnEx) SetSendTimeout ¶
func (*ConnEx) SetWriteBuffer ¶
type ConnExIfImp ¶
func NewConnExIfImp ¶
func NewConnExIfImp(parseHeader func(b []byte) (dataLen int, headerMsg interface{})) *ConnExIfImp
func (*ConnExIfImp) ParseHeader ¶
func (me *ConnExIfImp) ParseHeader(b []byte) (dataLen int, headerMsg interface{})
type DefaultMsgHeader ¶
type MacIP ¶
func (*MacIP) IPV6Address ¶
type MyServer ¶
type MyServer struct { IPFilterEnable bool ClientMap xmap.Map[int64, *MySrvClient] ServerName string TimeoutFunc func(client *MySrvClient) WriterFunc func(client *MySrvClient) ReadFunc func(server *MyServer, client *MySrvClient) bool IncomingData func(server *MyServer, client *MySrvClient, buf []byte) MaxIdleTime int64 GraceFd uintptr // contains filtered or unexported fields }
func NewMyServer ¶
func (*MyServer) GetClientById ¶
func (me *MyServer) GetClientById(id int64) *MySrvClient
func (*MyServer) GetClientCount ¶
func (*MyServer) GetUserData ¶
func (me *MyServer) GetUserData() interface{}
func (*MyServer) ParseHeader ¶
func (*MyServer) SetInterface ¶
func (*MyServer) SetSendBuffer ¶
func (*MyServer) SetUserData ¶
func (me *MyServer) SetUserData(data interface{})
type MySrvClient ¶
type MySrvClient struct { ///////////////////////////////////////////////////////// IsLogin cast.Bool DecodeMode int // contains filtered or unexported fields }
func (*MySrvClient) EnableKeepAlive ¶
func (me *MySrvClient) EnableKeepAlive(interval, count int) error
警告: 会引起socket超时失败
func (*MySrvClient) GetClientID ¶
func (me *MySrvClient) GetClientID() int64
func (*MySrvClient) GetCloseError ¶
func (me *MySrvClient) GetCloseError() string
///////////////////////////////////////////////////////////////////////////////////////
func (*MySrvClient) GetConn ¶
func (me *MySrvClient) GetConn() *ConnEx
func (*MySrvClient) GetCreateTime ¶
func (me *MySrvClient) GetCreateTime() int64
func (*MySrvClient) GetDefaultHeader ¶
func (me *MySrvClient) GetDefaultHeader() *DefaultMsgHeader
func (*MySrvClient) GetIP ¶
func (me *MySrvClient) GetIP() string
func (*MySrvClient) GetRemoteAddressString ¶
func (me *MySrvClient) GetRemoteAddressString() string
func (*MySrvClient) GetSendQueueLen ¶
func (me *MySrvClient) GetSendQueueLen() int
func (*MySrvClient) GetUserData ¶
func (me *MySrvClient) GetUserData() interface{}
func (*MySrvClient) IsClose ¶
func (me *MySrvClient) IsClose() bool
func (*MySrvClient) SendDequeue ¶
func (me *MySrvClient) SendDequeue() *sendQueue
func (*MySrvClient) SendNoHeader ¶
func (me *MySrvClient) SendNoHeader(msgType int32, data []byte, dataLen int) bool
func (*MySrvClient) SetUserData ¶
func (me *MySrvClient) SetUserData(data interface{})
type MySrvInf ¶
type MySrvInf interface { //false: refuse connect OnAccept(client *MySrvClient) bool OnClose(client *MySrvClient) //false: disconnect OnRequest(client *MySrvClient, data []byte) bool }
type MySrvInfImp ¶
type MySrvInfImp struct { AcceptFunc func(client *MySrvClient) bool CloseFunc func(client *MySrvClient) RequestFunc func(client *MySrvClient, data []byte) bool }
func NewMySrvInf ¶
func NewMySrvInf(accept func(client *MySrvClient) bool, close func(client *MySrvClient), request func(client *MySrvClient, data []byte) bool) *MySrvInfImp
func (*MySrvInfImp) OnAccept ¶
func (me *MySrvInfImp) OnAccept(client *MySrvClient) bool
func (*MySrvInfImp) OnClose ¶
func (me *MySrvInfImp) OnClose(client *MySrvClient)
func (*MySrvInfImp) OnRequest ¶
func (me *MySrvInfImp) OnRequest(client *MySrvClient, data []byte) bool
type NetExHeaderMsg ¶
type TcpListenerEx ¶
type TcpListenerEx struct { *net.TCPListener // contains filtered or unexported fields }
func NewTLSTcpServer ¶
func NewTLSTcpServer(host string, fd uintptr, config *TLSConfig) (*TcpListenerEx, error)
func NewTcpServer ¶
func NewTcpServer(host string, fd uintptr) (*TcpListenerEx, error)
func (*TcpListenerEx) Accept ¶
func (me *TcpListenerEx) Accept() (*ConnEx, error)
Click to show internal directories.
Click to hide internal directories.