Versions in this module Expand all Collapse all v0 v0.0.11 Jan 16, 2024 Changes in this version type Option + SocketReadBufSize int + SocketWriteBufSize int v0.0.10 Jan 9, 2024 Changes in this version + var ErrClosedAlready = errors.New("connection: connection closed already") + var ErrConnectionPanic = errors.New("connection: using in a wrong way") + var ErrRAddrIsNil = errors.New("connection: remote addr is nil") + var ErrUdpUnsupported = errors.New("connection: udp unsupported") + var ErrWriteChanFull = errors.New("connection: write channel full") + func ListenUdpWithAddr(addr string) (*net.UDPConn, error) + func TcpConnectTimeout(lAddr, rAddr string, timeout time.Duration) (net.Conn, error) + type IConnection interface + Close func() + Done func() <-chan error + Flush func() error + GetStat func() Stat + LocalAddr func() net.Addr + Read func(b []byte) (n int, rAddr net.Addr, err error) + ReadAtLeast func(buf []byte, min int) (n int, err error) + ReadLine func() (line []byte, isPrefix bool, err error) + Write func(b []byte) (n int, err error) + WriteByAddr func(b []byte, rAddr net.Addr) (n int, err error) + type ModOption func(option *Option) + type Option struct + LocalAddr string + ReadBufSize int + ReadTimeoutMs int + RemoteAddr string + TcpConnectTimeout time.Duration + WriteBufSize int + WriteChanFullBehavior WriteChanFullBehavior + WriteChanSize int + WriteTimeoutMs int + type Stat struct + ReadBytesSum uint64 + WroteBytesSum uint64 + type StatAtomic struct + ReadBytesSum atomicUtils.Uint64 + WroteBytesSum atomicUtils.Uint64 + type TcpClientConnection struct + func NewTcpClientConnection(modOptions ...ModOption) (*TcpClientConnection, error) + func NewTcpServerConnection(conn net.Conn, modOptions ...ModOption) (*TcpClientConnection, error) + func (c *TcpClientConnection) Close() + func (c *TcpClientConnection) Done() <-chan error + func (c *TcpClientConnection) Flush() error + func (c *TcpClientConnection) GetStat() (s Stat) + func (c *TcpClientConnection) LocalAddr() net.Addr + func (c *TcpClientConnection) Read(b []byte) (n int, rAddr net.Addr, err error) + func (c *TcpClientConnection) ReadAtLeast(buf []byte, min int) (n int, err error) + func (c *TcpClientConnection) ReadLine() (line []byte, isPrefix bool, err error) + func (c *TcpClientConnection) Write(b []byte) (n int, err error) + func (c *TcpClientConnection) WriteByAddr(b []byte, rAddr net.Addr) (n int, err error) + type TcpConnectHandle func(ctx context.Context, conn *TcpClientConnection) + type TcpServer struct + func NewTcpServer(handle TcpConnectHandle, modOptions ...ModOption) *TcpServer + func (s *TcpServer) Close() + func (s *TcpServer) RunLoop() error + type UdpConnection struct + func NewUdpConnection(modOptions ...ModOption) (*UdpConnection, error) + func (c *UdpConnection) Close() + func (c *UdpConnection) Done() <-chan error + func (c *UdpConnection) Flush() error + func (c *UdpConnection) GetStat() (s Stat) + func (c *UdpConnection) LocalAddr() net.Addr + func (c *UdpConnection) Read(b []byte) (n int, rAddr net.Addr, err error) + func (c *UdpConnection) ReadAtLeast(buf []byte, min int) (n int, err error) + func (c *UdpConnection) ReadLine() (line []byte, isPrefix bool, err error) + func (c *UdpConnection) Write(b []byte) (n int, err error) + func (c *UdpConnection) WriteByAddr(b []byte, rAddr net.Addr) (n int, err error) + type WriteChanFullBehavior int + const WriteChanFullBehaviorBlock + const WriteChanFullBehaviorReturnError