Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe creates a net.Listener and for addr and calls s.Serve with it.
Its behavior is very similar to net/http.ListenAndServe. In contrast to net/http.ListenAndServe it does not return net/http.ErrServerClosed when the s was closed. Instead it returns nil. Errors are only returned if an error occurred.
Callers may pass any of the following options to ListenAndServe:
- NotifyAddr
- WithAddr
- WithListener
See the documentation of the individual options for details. If the same option is passed more than once, the latest passed option wins. Unsupported options are silently ignored.
If neither UseListener nor UseAddr are passed the server listens on 127.0.0.1:0 by default, i.e. it chooses a random port and listens on the loopback interface only.
ListenAndServe blocks the current go routine.
Types ¶
type Option ¶
type Option func(*netutilOptions)
Option represents a configurable option for the helpers in netutil.
func NotifyAddr ¶
NotifyAddr passes a channel to ListenAndServe which is used to send the address the Server is listening on to the caller.
func WithAddr ¶
WithAddr sets the network address the server started by ListenAndServe will listen on.
func WithListener ¶
WithListener tells ListenAndServe to use the passed listener instead of creating a new one.