Documentation ¶
Index ¶
- Variables
- func ReadBuffer() (bytes int, isDefault bool)
- func SetDefaultProtoFunc(protoFunc ProtoFunc)
- func SetKeepAlive(keepalive bool)
- func SetKeepAlivePeriod(d time.Duration)
- func SetNoDelay(_noDelay bool)
- func SetReadBuffer(bytes int)
- func SetWriteBuffer(bytes int)
- func TryOptimize(conn net.Conn)
- func WriteBuffer() (bytes int, isDefault bool)
- type HubSocket
- type Message
- type Proto
- type ProtoFunc
- type Socket
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrProactivelyCloseSocket = errors.New("socket is closed proactively")
Functions ¶
func SetDefaultProtoFunc ¶
func SetDefaultProtoFunc(protoFunc ProtoFunc)
SetDefaultProtoFunc 设置默认的传输编码协议
func TryOptimize ¶
Types ¶
type HubSocket ¶
type HubSocket struct {
// contains filtered or unexported fields
}
HubSocket socket 仓库
type Socket ¶
type Socket interface { // ControlFD 获取原始句柄 ControlFD(f func(fd uintptr)) error // LocalAddr 获取socket本地的地址 LocalAddr() net.Addr // RemoteAddr 获取socket远端的地址 RemoteAddr() net.Addr // SetDeadline 设置超时时间 SetDeadline(t time.Time) error // SetReadDeadline 设置读取数据的超时时间 SetReadDeadline(t time.Time) error // SetWriteDeadline 设置发送数据的超时时间 SetWriteDeadline(t time.Time) error // WriteMessage 往链接中写入消息 WriteMessage(message Message) error // ReadMessage 从链接中读取消息头和消息体,并填充到消息对象中 ReadMessage(message Message) error // Read 从链接中读取字符 Read(b []byte) (n int, err error) // Write 写入字符到链接 Write(b []byte) (n int, err error) // Close 关闭链接 Close() error // Swap 链接的自定义数据,如果 newSwap不为空,则会替换内部数据,并返回 Swap(newSwap ...*dmap.Map) *dmap.Map // SwapLen 返回链接中自定义数据的长度 SwapLen() int // ID 返回链接的id ID() string // SetID 设置链接id SetID(string) // Reset 重置net.Conn Reset(netConn net.Conn, protoFunc ...ProtoFunc) // Raw 返回原始链接 Raw() net.Conn }
Click to show internal directories.
Click to hide internal directories.