Documentation ¶
Index ¶
- Constants
- Variables
- func RecoveryBuffer(data *[]byte)
- func Send(addr string, data []byte, retry *Retry) error
- func SendRecv(addr string, data []byte, length int, retry *Retry) ([]byte, error)
- func SendRecvWithTimeout(addr string, data []byte, receive int, timeout time.Duration, retry *Retry) ([]byte, error)
- func SendWithTimeout(addr string, data []byte, timeout time.Duration, retry *Retry) error
- type Conn
- func (c *Conn) Recv(length int, retry *Retry) ([]byte, error)
- func (c *Conn) RecvLine(retry *Retry) ([]byte, error)
- func (c *Conn) RecvWithTimeout(length int, timeout time.Duration, retry *Retry) ([]byte, error)
- func (c *Conn) Send(data []byte, retry *Retry) error
- func (c *Conn) SendRecv(data []byte, length int, retry *Retry) ([]byte, error)
- func (c *Conn) SendRecvWithTimeout(data []byte, timeout time.Duration, length int, retry *Retry) ([]byte, error)
- func (c *Conn) SendWithTimeout(data []byte, timeout time.Duration, retry *Retry) error
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetRecvBufferInterval(t time.Duration)
- func (c *Conn) SetRecvDeadline(t time.Time) error
- func (c *Conn) SetSendDeadline(t time.Time) error
- type Retry
Constants ¶
View Source
const ( UNKNOWN = iota ACTIVE ERROR )
Variables ¶
View Source
var ( // DefaultWaitTimeout 默认等待超时时间 DefaultWaitTimeout = time.Millisecond // DefaultConnTimeout 默认连接超时时间 DefaultConnTimeout = 30 * time.Second // DefaultRetryInterval 默认重试间隔 DefaultRetryInterval = 100 * time.Millisecond // DefaultReadBuffer 默认读取buffer大小 DefaultReadBuffer = 1 << 12 // DefaultServer 默认的服务名称 DefaultServer = "Default" )
Functions ¶
func RecoveryBuffer ¶
func RecoveryBuffer(data *[]byte)
RecoveryBuffer 用于回收已经不使用的 *[]byte 如果使用已经回收的资源,可能会造成panic,请注意
Types ¶
type Conn ¶
Conn 封装原始 net.conn 对象
func NewConnByNetConn ¶
NewConnByNetConn 通过原始的 net.Conn 链接建立 Conn 封装对象
func NewConnTLS ¶
NewConnTLS 通过tls建立
func (*Conn) Recv ¶
Recv 接受数据 length == 0 从 Conn一次读取立即返回 length < 0 从 Conn 接收所有数据,并将其返回,直到没有数据 length > 0 从 Conn 接收到对应的数据返回
func (*Conn) RecvWithTimeout ¶
RecvWithTimeout 读取已经超时的链接
func (*Conn) SendRecvWithTimeout ¶
func (c *Conn) SendRecvWithTimeout(data []byte, timeout time.Duration, length int, retry *Retry) ([]byte, error)
SendRecvWithTimeout 将数据写入并读出已经超时的链接
func (*Conn) SendWithTimeout ¶
SendWithTimeout 写入数据给已经超时的链接
func (*Conn) SetRecvBufferInterval ¶
SetRecvBufferInterval 读取缓存间隔时间
Click to show internal directories.
Click to hide internal directories.