multilistener

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

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

Listener implements a net.Listener interface but multiplexes connections from multiple listeners.

func New

func New(listeners ...net.Listener) (*Listener, error)

New creates an instance of a Listener using the given listeners. You must pass at least one listener. The new listener object listens for new connection on all the given listeners.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept will wait for a result from calling Accept from the underlying listeners. It will return an error if the multi-listener is closed.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the address of the first listener the multi-listener is using. The address of other listeners are not available.

func (*Listener) Close

func (l *Listener) Close() error

Close will close the multi-listener by iterating over its listeners and calling Close() on each one. If an error is encountered, it is returned. If multiple errors are encountered they are returned in a MutiError. Close will also shut down the background goroutines that are calling Accept() on the underlying listeners.

Calling Close() more than once will cause it to panic.

type MultiError

type MultiError struct {
	Errors []error
}

MultiError is a wrapper around a slice of errors that implements the error interface.

func (*MultiError) Error

func (m *MultiError) Error() string

Error concats the Error() messages of the underlying errors

Jump to

Keyboard shortcuts

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