Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ListenFunc = Listen
ListenFunc is a variable that holds the reference to the Listen function to use, so that it can be mocked for tests.
Functions ¶
func Listen ¶
Listen creates a Listener listening on the specified address. It returns the listener, the port it uses (0 if not listening on a TCP address), or an error.
The main purpose is to listen on port 0 and let the system select a free TCP port, and then get that port number back. The returned Listener should then be passed to a server's Serve method to start accepting connections.
Types ¶
type HostPortAddr ¶
HostPortAddr is a TCP-based net.Addr that contains the unresolved host name and port number. It is a value type, so that it can be value-compared for equality and used as a map key.
func ParseAddr ¶
func ParseAddr(s string, defaultPort int) (HostPortAddr, error)
ParseAddr parses s into a HostPortAddr, using defaultPort if no port is specified in s. The string should have the format host:port or just host.
func ParseSSHUserAddr ¶
func ParseSSHUserAddr(s string) (user string, addr HostPortAddr, err error)
ParseSSHUserAddr parses s into a HostPortAddr using the default SSH port if no port is provided. It returns the user specified in s as well as the parsed address, or an error. The string should have the format [user@]host[:port].
func (HostPortAddr) Network ¶
func (a HostPortAddr) Network() string
Network returns the network type for this address, which is always "tcp".
func (HostPortAddr) String ¶
func (a HostPortAddr) String() string
String returns the host:port form of the address.