Versions in this module Expand all Collapse all v1 v1.0.2 Dec 11, 2025 Changes in this version + var ErrNotTCPConn = errors.New("not a TCP connection") + var ErrNotUDPConn = errors.New("not a UDP connection") + func DataExchange(conn1, conn2 net.Conn, idleTimeout time.Duration, buffer1, buffer2 []byte) error + type RateLimiter struct + func NewRateLimiter(readBytesPerSecond, writeBytesPerSecond int64) *RateLimiter + func (rl *RateLimiter) Reset() + func (rl *RateLimiter) SetRate(readBytesPerSecond, writeBytesPerSecond int64) + func (rl *RateLimiter) WaitRead(bytes int64) + func (rl *RateLimiter) WaitWrite(bytes int64) + type StatConn struct + Conn net.Conn + RX *uint64 + Rate *RateLimiter + TX *uint64 + func NewStatConn(conn net.Conn, rx, tx *uint64, rate *RateLimiter) *StatConn + func (sc *StatConn) AsTCPConn() (*net.TCPConn, bool) + func (sc *StatConn) AsUDPConn() (*net.UDPConn, bool) + func (sc *StatConn) Close() error + func (sc *StatConn) CloseRead() error + func (sc *StatConn) CloseWrite() error + func (sc *StatConn) GetConn() net.Conn + func (sc *StatConn) GetRX() uint64 + func (sc *StatConn) GetRate() *RateLimiter + func (sc *StatConn) GetTX() uint64 + func (sc *StatConn) GetTotal() uint64 + func (sc *StatConn) IsTCP() bool + func (sc *StatConn) IsUDP() bool + func (sc *StatConn) LocalAddr() net.Addr + func (sc *StatConn) NetworkType() string + func (sc *StatConn) Read(b []byte) (int, error) + func (sc *StatConn) ReadFromUDP(b []byte) (int, *net.UDPAddr, error) + func (sc *StatConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error) + func (sc *StatConn) RemoteAddr() net.Addr + func (sc *StatConn) Reset() + func (sc *StatConn) SetDeadline(t time.Time) error + func (sc *StatConn) SetKeepAlive(keepalive bool) error + func (sc *StatConn) SetKeepAlivePeriod(d time.Duration) error + func (sc *StatConn) SetLinger(sec int) error + func (sc *StatConn) SetNoDelay(noDelay bool) error + func (sc *StatConn) SetReadBuffer(bytes int) error + func (sc *StatConn) SetReadDeadline(t time.Time) error + func (sc *StatConn) SetWriteBuffer(bytes int) error + func (sc *StatConn) SetWriteDeadline(t time.Time) error + func (sc *StatConn) Write(b []byte) (int, error) + func (sc *StatConn) WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error) + func (sc *StatConn) WriteToUDP(b []byte, addr *net.UDPAddr) (int, error) + type TimeoutReader struct + Conn net.Conn + Timeout time.Duration + func (tr *TimeoutReader) Read(b []byte) (int, error)