Documentation
¶
Index ¶
- func NewConn(c net.Conn) net.Conn
- type CloseNotifier
- type Conn
- func (T *Conn) Close() error
- func (T *Conn) CloseNotify() <-chan error
- func (T *Conn) DisableBackgroundRead(y bool)
- func (T *Conn) LocalAddr() net.Addr
- func (T *Conn) RawConn() net.Conn
- func (T *Conn) RawConnFull(p []byte) (net.Conn, int)
- func (T *Conn) Read(b []byte) (n int, err error)
- func (T *Conn) RemoteAddr() net.Addr
- func (T *Conn) SetBackgroundReadDiscard(y bool)
- func (T *Conn) SetDeadline(t time.Time) error
- func (T *Conn) SetReadDeadline(t time.Time) error
- func (T *Conn) SetReadLimit(remain int)
- func (T *Conn) SetWriteDeadline(t time.Time) error
- func (T *Conn) Write(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CloseNotifier ¶
type CloseNotifier interface {
CloseNotify() <-chan error // 事件通知
}
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) CloseNotify ¶
注意:这里会有两个通知,1)远程主动断开 2)本地调用断开 如果你是用于断开连接重连,需要判断返回的 error 状态。 error != nil 表示远程主动断开(一般用于这个) error == nil 表示本地调用断开(关闭连接,通道关闭,返回nil)
func (*Conn) DisableBackgroundRead ¶ added in v1.1.0
停止后台实时监听的连接关闭状态,在你自己调用Read或Write发生错误,依然 CloseNotify 返回连接关闭信号。
func (*Conn) RawConn ¶ added in v1.1.2
返回原始连接;如果在后台读取时候,收到1位数据。此时读取出源连接后,读取数据会少1位。造成数据不完整。 可以使用 RawConnFull判断有没有后台收到一位数据。
func (*Conn) RawConnFull ¶ added in v1.3.0
判断该源始连接是否完整可用。
p []byte 读取已经在后台得到的数据 net.Conn 源连接 int 0连接是完整的, >0 有后台数据
func (*Conn) RemoteAddr ¶
func (*Conn) SetBackgroundReadDiscard ¶ added in v1.0.9
后台读取丢弃,只要用于连接加入连接池后,期间收到的数据全部丢弃。 用于特殊环境,普通用户正常不需要用到他。
Click to show internal directories.
Click to hide internal directories.