mctcp

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderLen = 2

Variables

View Source
var (
	ErrClosed     = errors.New("pool closed")
	ErrBrokenConn = errors.New("broken connection")
)

Functions

func Packet2Stream

func Packet2Stream(data []byte, w io.Writer) error

func Stream2Packet

func Stream2Packet(r io.Reader) ([]byte, error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, size int, readBufferSize int, addr string) (*Client, error)

func (*Client) Closed

func (c *Client) Closed() bool

func (*Client) Read

func (c *Client) Read() ([]byte, error)

func (*Client) Write

func (c *Client) Write(buf []byte) error

Write select an available conn and then write data to it

type MarkConn

type MarkConn struct {
	*net.TCPConn
	// contains filtered or unexported fields
}

func NewMarkConn

func NewMarkConn(conn *net.TCPConn) *MarkConn

func (*MarkConn) Close

func (m *MarkConn) Close() error

func (*MarkConn) IsAvailable

func (m *MarkConn) IsAvailable() bool

type Reader

type Reader interface {
	Read() ([]byte, error)
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, size int, readBufferSize int, addr string) (*Server, error)

func (*Server) ListenAndAccept

func (s *Server) ListenAndAccept() error

func (*Server) Read

func (s *Server) Read() ([]byte, error)

func (*Server) Write

func (s *Server) Write(buf []byte) error

type TcpPool

type TcpPool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(ctx context.Context, size int, readBufferSize int) *TcpPool

func (*TcpPool) Closed

func (p *TcpPool) Closed() bool

func (*TcpPool) Push

func (p *TcpPool) Push(conn *net.TCPConn)

func (*TcpPool) Read

func (p *TcpPool) Read() ([]byte, error)

func (*TcpPool) RegisterTcpReadFailed

func (p *TcpPool) RegisterTcpReadFailed(fn func(err error))

func (*TcpPool) Write

func (p *TcpPool) Write(buf []byte) error

type Writer

type Writer interface {
	Write(buf []byte) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL