Documentation ¶
Overview ¶
Package channel_listener contains a listener that is able to pass arbitrary connections through a channel.
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 is an implementation of a network listener that accepts connections from a channel. This allows for a flexible way to handle incoming connections.
func New ¶
New creates a new instance of Listener. net.Conn from the channel in are passed to Listener.Accept calls. addr is passed through to Listener.Addr.
func (*Listener) Accept ¶
Accept waits for and returns the next connection from the channel. If the listener is closed, it returns the error used to close.
func (*Listener) Close ¶
Close closes the listener and signals any goroutines in Listener.Accept to stop waiting. It calls Listener.CloseWithErr with nil.
func (*Listener) CloseWithErr ¶
CloseWithErr allows closing the listener with a specific error. This error will be returned by Listener.Accept when the listener is closed. Only the error from the first time this is called will be returned. If the passed err is nil, the error used to close is net.ErrClosed.