stringmux

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	StringMuxByte  uint8 = 0b11001000
	MaxLenStreamID int   = 0xFF
)
View Source
const DefaultMTU uint32 = 8192

Variables

View Source
var (
	ErrConnAlreadyExists = errors.New("connection already exists")
	ErrConnNotFound      = errors.New("connection not found")
)
View Source
var (
	ErrStreamIDTooLarge = errors.New("stream id too large")
	ErrInvalidHeader    = errors.New("invalid first byte")
)

Functions

func Marshal

func Marshal(streamID string, data []byte) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte) (string, []byte, error)

Types

type Conn

type Conn interface {
	net.Conn
	CloseWrite()
	StreamID() string
	Done() <-chan struct{}
}

type Params

type Params struct {
	Log            logger.Logger
	Conn           net.Conn
	MTU            uint32
	ReadChanSize   int
	ReadBufferSize int
}

type StringMux

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

func New

func New(params Params) *StringMux

func (*StringMux) AcceptConn

func (m *StringMux) AcceptConn() (Conn, error)

AcceptConn reads from Conns channel. It returns io.ErrClosedPipe when the channel is closed. Users should use either AcceptConn or Conns, but never both.

func (*StringMux) Close

func (m *StringMux) Close() error

func (*StringMux) Conns

func (m *StringMux) Conns() <-chan Conn

Conns is the channel with incoming connections. Users should use either AcceptConn or Conns, but never both.

func (*StringMux) Done

func (m *StringMux) Done() <-chan struct{}

func (*StringMux) GetConn

func (m *StringMux) GetConn(streamID string) (Conn, error)

func (*StringMux) LocalAddr

func (m *StringMux) LocalAddr() net.Addr

func (*StringMux) RemoteAddr

func (m *StringMux) RemoteAddr() net.Addr

Jump to

Keyboard shortcuts

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