addr

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func Listen(addr net.Addr) (l net.Listener, port int, err error)

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

type HostPortAddr struct {
	Host string
	Port int
}

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.

Jump to

Keyboard shortcuts

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