Documentation ¶
Index ¶
- Constants
- Variables
- type Agent
- type CAFile
- type Conn
- type ConnSet
- type HttpServer
- type KCPClient
- type KCPServer
- type KcpCfg
- type MsgParser
- type NetConn
- func (netConn *NetConn) Close()
- func (netConn *NetConn) Destroy()
- func (netConn *NetConn) GetRecyclerReaderBytes() func(data []byte)
- func (netConn *NetConn) GetRemoteIp() string
- func (netConn *NetConn) IsConnected() bool
- func (netConn *NetConn) LocalAddr() net.Addr
- func (netConn *NetConn) Read(b []byte) (int, error)
- func (netConn *NetConn) ReadMsg() ([]byte, error)
- func (netConn *NetConn) ReleaseReadMsg(byteBuff []byte)
- func (netConn *NetConn) RemoteAddr() net.Addr
- func (netConn *NetConn) SetReadDeadline(d time.Duration)
- func (netConn *NetConn) SetWriteDeadline(d time.Duration)
- func (netConn *NetConn) Write(b []byte) error
- func (netConn *NetConn) WriteMsg(args ...[]byte) error
- func (netConn *NetConn) WriteRawMsg(args []byte) error
- type NoDelayCfg
- type TCPClient
- type TCPServer
- type WSClient
- type WSConn
- type WSHandler
- type WSServer
- type WebsocketConnSet
Constants ¶
View Source
const ( DefaultNoDelay = 1 DefaultIntervalMill = 10 DefaultResend = 2 DefaultCongestionControl = 1 DefaultMtu = 1400 DefaultSndWndSize = 4096 DefaultRcvWndSize = 4096 DefaultStreamMode = true DefaultDSCP = 46 DefaultDataShards = 10 DefaultParityShards = 0 DefaultReadDeadlineMill = 15 * time.Second DefaultWriteDeadlineMill = 15 * time.Second DefaultMaxConnNum = 20000 )
View Source
const ( Default_ReadDeadline = time.Second * 30 //默认读超时30s Default_WriteDeadline = time.Second * 30 //默认写超时30s Default_MaxConnNum = 1000000 //默认最大连接数 Default_PendingWriteNum = 100000 //单连接写消息Channel容量 Default_MinMsgLen = 2 //最小消息长度2byte Default_LenMsgLen = 2 //包头字段长度占用2byte Default_MaxMsgLen = 65535 //最大消息长度 )
Variables ¶
View Source
var DefaultMaxHeaderBytes = 1 << 20
Functions ¶
This section is empty.
Types ¶
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func (*HttpServer) SetCAFile ¶
func (slf *HttpServer) SetCAFile(caFile []CAFile)
func (*HttpServer) Start ¶
func (slf *HttpServer) Start()
type KCPClient ¶
type KCPClient struct { sync.Mutex Addr string ConnNum int ConnectInterval time.Duration PendingWriteNum int ReadDeadline time.Duration WriteDeadline time.Duration AutoReconnect bool NewAgent func(conn *NetConn) Agent // msg parser MsgParser // contains filtered or unexported fields }
func (*KCPClient) GetCloseFlag ¶
type KcpCfg ¶
type KcpCfg struct { ListenAddr string // 监听地址 MaxConnNum int //最大连接数 NoDelay *NoDelayCfg Mtu *int // mtu大小 SndWndSize *int // 发送窗口大小,默认1024 RcvWndSize *int // 接收窗口大小,默认1024 ReadDeadlineMill *time.Duration // 读超时毫秒 WriteDeadlineMill *time.Duration // 写超时毫秒 StreamMode *bool // 是否打开流模式,默认true DSCP *int // 差分服务代码点,默认46 ReadBuffSize *int // 读Buff大小,默认 WriteBuffSize *int // 写Buff大小 // 用于 FEC(前向纠错)的数据分片和校验分片数量,,默认10,0 DataShards *int ParityShards *int LittleEndian bool //是否小端序 LenMsgLen int //消息头占用byte数量,只能是1byte,2byte,4byte。如果是4byte,意味着消息最大可以是math.MaxUint32(4GB) MinMsgLen uint32 //最小消息长度 MaxMsgLen uint32 //最大消息长度,超过判定不合法,断开连接 PendingWriteNum int //写channel最大消息数量 }
type MsgParser ¶
type MsgParser struct { LenMsgLen int MinMsgLen uint32 MaxMsgLen uint32 LittleEndian bool bytespool.IBytesMemPool }
MsgParser -------------- | len | data | --------------
func (*MsgParser) GetRecyclerReaderBytes ¶
type NetConn ¶
func (*NetConn) GetRecyclerReaderBytes ¶
func (*NetConn) GetRemoteIp ¶
func (*NetConn) IsConnected ¶
func (*NetConn) ReleaseReadMsg ¶
func (*NetConn) RemoteAddr ¶
func (*NetConn) SetReadDeadline ¶
func (*NetConn) SetWriteDeadline ¶
func (*NetConn) WriteRawMsg ¶
type NoDelayCfg ¶
type NoDelayCfg struct { NoDelay int // 是否启用 nodelay模式,0不启用;1启用 IntervalMill int // 协议内部工作的 interval,单位毫秒,比如 10ms或者 20ms Resend int // 快速重传模式,默认0关闭,可以设置2(2次ACK跨越将会直接重传) CongestionControl int // 是否关闭流控,默认是0代表不关闭,1代表关闭 }
NoDelayCfg
普通模式: ikcp_nodelay(kcp, 0, 40, 0, 0); 极速模式: ikcp_nodelay(kcp, 1, 10, 2, 1);
type TCPClient ¶
type TCPClient struct { sync.Mutex Addr string ConnNum int ConnectInterval time.Duration PendingWriteNum int ReadDeadline time.Duration WriteDeadline time.Duration AutoReconnect bool NewAgent func(conn *NetConn) Agent // msg parser MsgParser // contains filtered or unexported fields }
func (*TCPClient) GetCloseFlag ¶
type TCPServer ¶
type TCPServer struct { Addr string MaxConnNum int PendingWriteNum int ReadDeadline time.Duration WriteDeadline time.Duration NewAgent func(conn Conn) Agent MsgParser // contains filtered or unexported fields }
func (*TCPServer) GetNetMemPool ¶
func (server *TCPServer) GetNetMemPool() bytespool.IBytesMemPool
func (*TCPServer) SetNetMemPool ¶
func (server *TCPServer) SetNetMemPool(memPool bytespool.IBytesMemPool)
type WSClient ¶
type WSConn ¶
func (*WSConn) RemoteAddr ¶
type WSHandler ¶
type WSHandler struct {
// contains filtered or unexported fields
}
func (*WSHandler) ServeHTTP ¶
func (handler *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*WSHandler) SetMessageType ¶
type WSServer ¶
type WSServer struct { Addr string MaxConnNum int PendingWriteNum int MaxMsgLen uint32 HTTPTimeout time.Duration CertFile string KeyFile string NewAgent func(*WSConn) Agent // contains filtered or unexported fields }
func (*WSServer) SetMessageType ¶
type WebsocketConnSet ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.