Documentation ¶
Index ¶
- Variables
- type Conn
- type ErrNotMatched
- type ErrorHandler
- type Listener
- func (m *Listener) Accept() (net.Conn, error)
- func (m *Listener) Addr() net.Addr
- func (m *Listener) Close() error
- func (m *Listener) HandleError(h ErrorHandler)
- func (m *Listener) HandleSettings(h SettingsHandler)
- func (m *Listener) Match(matchers ...Matcher) net.Listener
- func (m *Listener) Serve() error
- func (m *Listener) ServeAsync(matcher Matcher, serve func(l net.Listener) error)
- func (m *Listener) SetReadTimeout(t time.Duration)
- type Matcher
- type Server
- type SettingsHandler
Constants ¶
This section is empty.
Variables ¶
var ErrListenerClosed = errListenerClosed("mux: listener closed")
ErrListenerClosed is returned from muxListener.Accept when the underlying listener is closed.
Functions ¶
This section is empty.
Types ¶
type ErrNotMatched ¶
type ErrNotMatched struct {
// contains filtered or unexported fields
}
ErrNotMatched is returned whenever a connection is not matched by any of the matchers registered in the multiplexer.
func (ErrNotMatched) Error ¶
func (e ErrNotMatched) Error() string
func (ErrNotMatched) Temporary ¶
func (e ErrNotMatched) Temporary() bool
Temporary implements the net.Error interface.
func (ErrNotMatched) Timeout ¶
func (e ErrNotMatched) Timeout() bool
Timeout implements the net.Error interface.
type ErrorHandler ¶
ErrorHandler handles an error and notifies the listener on whether it should continue serving.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener represents a listener used for multiplexing protocols.
func New ¶
New announces on the local network address laddr. The syntax of laddr is "host:port", like "127.0.0.1:8080". If host is omitted, as in ":8080", New listens on all available interfaces instead of just the interface with the given host address. Listening on a hostname is not recommended because this creates a socket for at most one of its IP addresses.
func (*Listener) HandleError ¶
func (m *Listener) HandleError(h ErrorHandler)
HandleError registers an error handler that handles listener errors.
func (*Listener) HandleSettings ¶
func (m *Listener) HandleSettings(h SettingsHandler)
HandleSettings 处理连接设置的函数,给予调用者一个干预系统级设置的机会
func (*Listener) Match ¶
Match returns a net.Listener that sees (i.e., accepts) only the connections matched by at least one of the matcher.
func (*Listener) ServeAsync ¶
ServeAsync adds a protocol based on the matcher and serves it.
func (*Listener) SetReadTimeout ¶
SetReadTimeout sets a timeout for the read of matchers.
type Matcher ¶
Matcher matches a connection based on its content.
func MatchPrefix ¶
MatchPrefix returns a matcher that matches a connection if it starts with any of the strings in strs.