mio

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosedByRemote    error = errors.Join(net.ErrClosed, errors.New("closed by remote"))
	ErrMainConnClosed    error = errors.Join(net.ErrClosed, errors.New("main conn closed"))
	ErrDialingIsCanceled error = errors.New("dial is canceled")
	ErrReadBufIsFull     error = errors.New("read buf is full")
)

Functions

func New

func New(c net.Conn, options ...any) (m *conn)

Types

type Conn

type Conn interface {
	koNet.ContextDialer
	koNet.Listener
	// Done returns a channel that will be closed when the connection is closed.
	Done() <-chan struct{}
	// SubConns returns a map of the currently active sub-connections. The keys of the map are the sub-connection IDs.
	SubConns() map[uint16]SubConn
	// LocalAddr returns the local network address.
	LocalAddr() net.Addr
	// RemoteAddr returns the remote network address.
	RemoteAddr() net.Addr
	// Latency returns the current estimated round-trip time (RTT) or latency to the remote peer.
	Latency() time.Duration
}

Multi-connections in one connection. A pipeListener on net.Conn.

type MaxWriteSize added in v0.2.3

type MaxWriteSize int

MaxWriteSize, the data payload size, must be between 1 and 65535 bytes.

type PackType added in v0.3.3

type PackType byte
const (
	NOOP   PackType = 0
	DIAL   PackType = 1
	ACCEPT PackType = 2
	CLOSE  PackType = 3
	DATA   PackType = 4
	PING   PackType = 5
	ACK    PackType = 6
)

type PingInterval added in v0.2.3

type PingInterval time.Duration

PingInterval specifies the interval at which ping messages are sent to check the connection latency.

type PingTimeout added in v0.2.3

type PingTimeout time.Duration

PingTimeout specifies the maximum amount of time to wait for a response to a ping message when checking connection latency.

type SubConn

type SubConn interface {
	// Id returns the unique identifier for this sub-connection.
	Id() uint16
	// LocalAddr returns the local network address for this sub-connection.
	LocalAddr() net.Addr
	// RemoteAddr returns the remote network address for this sub-connection.
	RemoteAddr() net.Addr
	// Context returns the Dial's context.
	Context() context.Context
}

Jump to

Keyboard shortcuts

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