listenmux

package
v0.33.1-rc Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Closed = errs.New("listener closed")

Closed is returned by routed listeners when the mux is closed.

Functions

This section is empty.

Types

type Mux

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

Mux lets one multiplex a listener into different listeners based on the first bytes sent on the connection.

func New

func New(base net.Listener, prefixLen int) *Mux

New creates a mux that reads the prefixLen bytes from any connections Accepted by the passed in listener and dispatches to the appropriate route.

func (*Mux) Default

func (m *Mux) Default() net.Listener

Default returns the net.Listener that is used if no route matches.

func (*Mux) Route

func (m *Mux) Route(prefix string) net.Listener

Route returns a listener that will be used if the first bytes are the given prefix. The length of the prefix must match the original passed in prefixLen.

func (*Mux) Run

func (m *Mux) Run(ctx context.Context) error

Run calls listen on the provided listener and passes connections to the routed listeners.

Jump to

Keyboard shortcuts

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