Documentation
¶
Index ¶
- func ListenAndServe(addr string, handler func(*TCPConn)) error
- type TCPConn
- func (t *TCPConn) AsyncRead(handleFunc func([]byte, error))
- func (t *TCPConn) AsyncWrite(data []byte, callback func(error))
- func (t *TCPConn) Close()
- func (t *TCPConn) Done() <-chan struct{}
- func (t *TCPConn) IsClosed() bool
- func (t *TCPConn) LocalAddr() string
- func (t *TCPConn) OnMessage(handleFunc func([]byte)) error
- func (t *TCPConn) Read() ([]byte, error)
- func (t *TCPConn) RemoteAddr() string
- func (t *TCPConn) SetKeepAlive(keepalive bool) error
- func (t *TCPConn) SetKeepAlivePeriod(d time.Duration) error
- func (t *TCPConn) SetLogger(logger *log.Logger)
- func (t *TCPConn) SetTimeouts(readTimeout, writeTimeout time.Duration)
- func (t *TCPConn) StartHeartbeat(interval time.Duration, heartbeatMsg []byte)
- func (t *TCPConn) StopHeartbeat()
- func (t *TCPConn) Write(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe 监听TCP连接
Types ¶
type TCPConn ¶
type TCPConn struct {
// contains filtered or unexported fields
}
TCPConn TCP连接封装
func (*TCPConn) AsyncWrite ¶
AsyncWrite 异步写入消息
func (*TCPConn) SetKeepAlive ¶
SetKeepAlive 设置TCP KeepAlive
func (*TCPConn) SetKeepAlivePeriod ¶
SetKeepAlivePeriod 设置KeepAlive间隔
func (*TCPConn) SetTimeouts ¶
SetTimeouts 设置读写超时
func (*TCPConn) StartHeartbeat ¶
StartHeartbeat 启动心跳机制
Click to show internal directories.
Click to hide internal directories.