package net

Import Path
	net (on golang.org and go.dev)

Dependency Relation
	imports 17 packages, and imported by 17 packages

Involved Source Files
	    addrselect.go
	    cgo_stub.go
	    conf.go
	    dial.go
	    dnsclient.go
	    dnsclient_unix.go
	    dnsconfig_unix.go
	    error_posix.go
	    error_unix.go
	    fd_posix.go
	    fd_unix.go
	    file.go
	    file_unix.go
	    hook.go
	    hook_unix.go
	    hosts.go
	    interface.go
	    interface_linux.go
	    ip.go
	    iprawsock.go
	    iprawsock_posix.go
	    ipsock.go
	    ipsock_posix.go
	    lookup.go
	    lookup_unix.go
	    mac.go
	d-> net.go
	    nss.go
	    parse.go
	    pipe.go
	    port.go
	    port_unix.go
	    rawconn.go
	    sendfile_linux.go
	    sock_cloexec.go
	    sock_linux.go
	    sock_posix.go
	    sockaddr_posix.go
	    sockopt_linux.go
	    sockopt_posix.go
	    sockoptip_linux.go
	    sockoptip_posix.go
	    splice_linux.go
	    tcpsock.go
	    tcpsock_posix.go
	    tcpsockopt_posix.go
	    tcpsockopt_unix.go
	    udpsock.go
	    udpsock_posix.go
	    unixsock.go
	    unixsock_posix.go
	    writev_unix.go

Exported Type Names

type Addr (interface) Addr represents a network end point address. The two methods Network and String conventionally return strings that can be passed as the arguments to Dial, but the exact form and meaning of the strings is up to the implementation. (T) Network() string (T) String() string *IPAddr *IPNet *TCPAddr *UDPAddr *UnixAddr T : expvar.Var T : fmt.Stringer func InterfaceAddrs() ([]Addr, error) func Conn.LocalAddr() Addr func Conn.RemoteAddr() Addr func (*Interface).Addrs() ([]Addr, error) func (*Interface).MulticastAddrs() ([]Addr, error) func (*IPConn).ReadFrom(b []byte) (int, Addr, error) func Listener.Addr() Addr func PacketConn.LocalAddr() Addr func PacketConn.ReadFrom(p []byte) (n int, addr Addr, err error) func (*TCPListener).Addr() Addr func (*UDPConn).ReadFrom(b []byte) (int, Addr, error) func (*UnixConn).ReadFrom(b []byte) (int, Addr, error) func (*UnixListener).Addr() Addr func crypto/tls.(*Conn).LocalAddr() Addr func crypto/tls.(*Conn).RemoteAddr() Addr func (*IPConn).WriteTo(b []byte, addr Addr) (int, error) func PacketConn.WriteTo(p []byte, addr Addr) (n int, err error) func (*UDPConn).WriteTo(b []byte, addr Addr) (int, error) func (*UnixConn).WriteTo(b []byte, addr Addr) (int, error)
type AddrError (struct) Addr string Err string (*T) Error() string (*T) Temporary() bool (*T) Timeout() bool *T : Error *T : error
type Buffers ([]) Buffers contains zero or more runs of bytes to write. On certain machines, for certain types of connections, this is optimized into an OS-specific batch write operation (such as "writev"). (*T) Read(p []byte) (n int, err error) (*T) WriteTo(w io.Writer) (n int64, err error) *T : io.Reader *T : io.WriterTo
type Conn (interface) Conn is a generic stream-oriented network connection. Multiple goroutines may invoke methods on a Conn simultaneously. (T) Close() error (T) LocalAddr() Addr (T) Read(b []byte) (n int, err error) (T) RemoteAddr() Addr (T) SetDeadline(t time.Time) error (T) SetReadDeadline(t time.Time) error (T) SetWriteDeadline(t time.Time) error (T) Write(b []byte) (n int, err error) *IPConn *TCPConn *UDPConn *UnixConn crypto/tls.(*Conn) T : io.Closer T : io.ReadCloser T : io.Reader T : io.ReadWriteCloser T : io.ReadWriter T : io.WriteCloser T : io.Writer func Dial(network, address string) (Conn, error) func DialTimeout(network, address string, timeout time.Duration) (Conn, error) func FileConn(f *os.File) (c Conn, err error) func Pipe() (Conn, Conn) func Pipe() (Conn, Conn) func (*Dialer).Dial(network, address string) (Conn, error) func (*Dialer).DialContext(ctx context.Context, network, address string) (Conn, error) func Listener.Accept() (Conn, error) func (*TCPListener).Accept() (Conn, error) func (*UnixListener).Accept() (Conn, error) func net/http.Hijacker.Hijack() (Conn, *bufio.ReadWriter, error) func net/http/httputil.(*ClientConn).Hijack() (c Conn, r *bufio.Reader) func net/http/httputil.(*ServerConn).Hijack() (Conn, *bufio.Reader) func crypto/tls.(*Dialer).Dial(network, addr string) (Conn, error) func crypto/tls.(*Dialer).DialContext(ctx context.Context, network, addr string) (Conn, error) func net/http/httputil.NewClientConn(c Conn, r *bufio.Reader) *httputil.ClientConn func net/http/httputil.NewProxyClientConn(c Conn, r *bufio.Reader) *httputil.ClientConn func net/http/httputil.NewServerConn(c Conn, r *bufio.Reader) *httputil.ServerConn func net/smtp.NewClient(conn Conn, host string) (*smtp.Client, error) func crypto/tls.Client(conn Conn, config *tls.Config) *tls.Conn func crypto/tls.Server(conn Conn, config *tls.Config) *tls.Conn
type Dialer (struct) A Dialer contains options for connecting to an address. The zero value for each field is equivalent to dialing without that option. Dialing with the zero value of Dialer is therefore equivalent to just calling the Dial function. It is safe to call Dialer's methods concurrently. Cancel <-chan struct{} Control func(network, address string, c syscall.RawConn) error Deadline time.Time DualStack bool FallbackDelay time.Duration KeepAlive time.Duration LocalAddr Addr Resolver *Resolver Timeout time.Duration (*T) Dial(network, address string) (Conn, error) (*T) DialContext(ctx context.Context, network, address string) (Conn, error) func crypto/tls.DialWithDialer(dialer *Dialer, network, addr string, config *tls.Config) (*tls.Conn, error)
type DNSConfigError (struct) DNSConfigError represents an error reading the machine's DNS configuration. (No longer used; kept for compatibility.) Err error (*T) Error() string (*T) Temporary() bool (*T) Timeout() bool (*T) Unwrap() error *T : Error *T : error
type DNSError (struct) DNSError represents a DNS lookup error. Err string IsNotFound bool IsTemporary bool IsTimeout bool Name string Server string (*T) Error() string (*T) Temporary() bool (*T) Timeout() bool *T : Error *T : error
type Error (interface) An Error represents a network error. (T) Error() builtin.string (T) Temporary() bool (T) Timeout() bool *AddrError *DNSConfigError *DNSError InvalidAddrError *OpError UnknownNetworkError net/url.(*Error) internal/poll.(*DeadlineExceededError) syscall.Errno T : error
type Flags uint (T) String() string T : expvar.Var T : fmt.Stringer func vendor/golang.org/x/net/nettest.RoutedInterface(network string, flags Flags) (*Interface, error) const FlagBroadcast const FlagLoopback const FlagMulticast const FlagPointToPoint const FlagUp
type HardwareAddr ([]) A HardwareAddr represents a physical hardware address. (T) String() string T : expvar.Var T : fmt.Stringer func ParseMAC(s string) (hw HardwareAddr, err error)
type Interface (struct) Interface represents a mapping between network interface name and index. It also represents network interface facility information. Flags Flags HardwareAddr HardwareAddr Index int MTU int Name string (*T) Addrs() ([]Addr, error) (*T) MulticastAddrs() ([]Addr, error) func InterfaceByIndex(index int) (*Interface, error) func InterfaceByName(name string) (*Interface, error) func Interfaces() ([]Interface, error) func vendor/golang.org/x/net/nettest.LoopbackInterface() (*Interface, error) func vendor/golang.org/x/net/nettest.RoutedInterface(network string, flags Flags) (*Interface, error) func ListenMulticastUDP(network string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error) func vendor/golang.org/x/net/nettest.MulticastSource(network string, ifi *Interface) (IP, error)
type InvalidAddrError string (T) Error() string (T) Temporary() bool (T) Timeout() bool T : Error T : error
type IP ([]) An IP is a single IP address, a slice of bytes. Functions in this package accept either 4-byte (IPv4) or 16-byte (IPv6) slices as input. Note that in this documentation, referring to an IP address as an IPv4 address or an IPv6 address is a semantic property of the address, not just the length of the byte slice: a 16-byte slice can still be an IPv4 address. (T) DefaultMask() IPMask (T) Equal(x IP) bool (T) IsGlobalUnicast() bool (T) IsInterfaceLocalMulticast() bool (T) IsLinkLocalMulticast() bool (T) IsLinkLocalUnicast() bool (T) IsLoopback() bool (T) IsMulticast() bool (T) IsUnspecified() bool (T) MarshalText() ([]byte, error) (T) Mask(mask IPMask) IP (T) String() string (T) To16() IP (T) To4() IP (*T) UnmarshalText(text []byte) error T : encoding.TextMarshaler *T : encoding.TextUnmarshaler T : expvar.Var T : fmt.Stringer func IPv4(a, b, c, d byte) IP func LookupIP(host string) ([]IP, error) func ParseCIDR(s string) (IP, *IPNet, error) func ParseIP(s string) IP func IP.Mask(mask IPMask) IP func IP.To16() IP func IP.To4() IP func (*Resolver).LookupIP(ctx context.Context, network, host string) ([]IP, error) func vendor/golang.org/x/net/nettest.MulticastSource(network string, ifi *Interface) (IP, error) func IP.Equal(x IP) bool func (*IPNet).Contains(ip IP) bool var IPv4allrouter var IPv4allsys var IPv4bcast var IPv4zero var IPv6interfacelocalallnodes var IPv6linklocalallnodes var IPv6linklocalallrouters var IPv6loopback var IPv6unspecified var IPv6zero
type IPAddr (struct) IPAddr represents the address of an IP end point. IP IP Zone string (*T) Network() string (*T) String() string *T : Addr *T : expvar.Var *T : fmt.Stringer func ResolveIPAddr(network, address string) (*IPAddr, error) func (*IPConn).ReadFromIP(b []byte) (int, *IPAddr, error) func (*IPConn).ReadMsgIP(b, oob []byte) (n, oobn, flags int, addr *IPAddr, err error) func (*Resolver).LookupIPAddr(ctx context.Context, host string) ([]IPAddr, error) func DialIP(network string, laddr, raddr *IPAddr) (*IPConn, error) func ListenIP(network string, laddr *IPAddr) (*IPConn, error) func (*IPConn).WriteMsgIP(b, oob []byte, addr *IPAddr) (n, oobn int, err error) func (*IPConn).WriteToIP(b []byte, addr *IPAddr) (int, error)
type IPConn (struct) IPConn is the implementation of the Conn and PacketConn interfaces for IP network connections. (*T) Close() error (*T) File() (f *os.File, err error) (*T) LocalAddr() Addr (*T) Read(b []byte) (int, error) (*T) ReadFrom(b []byte) (int, Addr, error) (*T) ReadFromIP(b []byte) (int, *IPAddr, error) (*T) ReadMsgIP(b, oob []byte) (n, oobn, flags int, addr *IPAddr, err error) (*T) RemoteAddr() Addr (*T) SetDeadline(t time.Time) error (*T) SetReadBuffer(bytes int) error (*T) SetReadDeadline(t time.Time) error (*T) SetWriteBuffer(bytes int) error (*T) SetWriteDeadline(t time.Time) error (*T) SyscallConn() (syscall.RawConn, error) (*T) Write(b []byte) (int, error) (*T) WriteMsgIP(b, oob []byte, addr *IPAddr) (n, oobn int, err error) (*T) WriteTo(b []byte, addr Addr) (int, error) (*T) WriteToIP(b []byte, addr *IPAddr) (int, error) *T : Conn *T : PacketConn *T : io.Closer *T : io.ReadCloser *T : io.Reader *T : io.ReadWriteCloser *T : io.ReadWriter *T : io.WriteCloser *T : io.Writer *T : syscall.Conn func DialIP(network string, laddr, raddr *IPAddr) (*IPConn, error) func ListenIP(network string, laddr *IPAddr) (*IPConn, error)
type IPMask ([]) An IPMask is a bitmask that can be used to manipulate IP addresses for IP addressing and routing. See type IPNet and func ParseCIDR for details. (T) Size() (ones, bits int) (T) String() string T : expvar.Var T : fmt.Stringer func CIDRMask(ones, bits int) IPMask func IPv4Mask(a, b, c, d byte) IPMask func IP.DefaultMask() IPMask func IP.Mask(mask IPMask) IP
type IPNet (struct) An IPNet represents an IP network. IP IP Mask IPMask (*T) Contains(ip IP) bool (*T) Network() string (*T) String() string *T : Addr *T : expvar.Var *T : fmt.Stringer func ParseCIDR(s string) (IP, *IPNet, error)
type ListenConfig (struct) ListenConfig contains options for listening to an address. Control func(network, address string, c syscall.RawConn) error KeepAlive time.Duration (*T) Listen(ctx context.Context, network, address string) (Listener, error) (*T) ListenPacket(ctx context.Context, network, address string) (PacketConn, error)
type Listener (interface) A Listener is a generic network listener for stream-oriented protocols. Multiple goroutines may invoke methods on a Listener simultaneously. (T) Accept() (Conn, error) (T) Addr() Addr (T) Close() error *TCPListener *UnixListener T : io.Closer func FileListener(f *os.File) (ln Listener, err error) func Listen(network, address string) (Listener, error) func (*ListenConfig).Listen(ctx context.Context, network, address string) (Listener, error) func crypto/tls.Listen(network, laddr string, config *tls.Config) (Listener, error) func crypto/tls.NewListener(inner Listener, config *tls.Config) Listener func vendor/golang.org/x/net/nettest.NewLocalListener(network string) (Listener, error) func net/http.Serve(l Listener, handler http.Handler) error func net/http.ServeTLS(l Listener, handler http.Handler, certFile, keyFile string) error func net/http.(*Server).Serve(l Listener) error func net/http.(*Server).ServeTLS(l Listener, certFile, keyFile string) error func net/http/fcgi.Serve(l Listener, handler http.Handler) error func net/rpc.Accept(lis Listener) func net/rpc.(*Server).Accept(lis Listener) func crypto/tls.NewListener(inner Listener, config *tls.Config) Listener
type MX (struct) An MX represents a single DNS MX record. Host string Pref uint16 func LookupMX(name string) ([]*MX, error) func (*Resolver).LookupMX(ctx context.Context, name string) ([]*MX, error)
type NS (struct) An NS represents a single DNS NS record. Host string func LookupNS(name string) ([]*NS, error) func (*Resolver).LookupNS(ctx context.Context, name string) ([]*NS, error)
type OpError (struct) OpError is the error type usually returned by functions in the net package. It describes the operation, network type, and address of an error. Addr Addr Err error Net string Op string Source Addr (*T) Error() string (*T) Temporary() bool (*T) Timeout() bool (*T) Unwrap() error *T : Error *T : error
type PacketConn (interface) PacketConn is a generic packet-oriented network connection. Multiple goroutines may invoke methods on a PacketConn simultaneously. (T) Close() error (T) LocalAddr() Addr (T) ReadFrom(p []byte) (n int, addr Addr, err error) (T) SetDeadline(t time.Time) error (T) SetReadDeadline(t time.Time) error (T) SetWriteDeadline(t time.Time) error (T) WriteTo(p []byte, addr Addr) (n int, err error) *IPConn *UDPConn *UnixConn T : io.Closer func FilePacketConn(f *os.File) (c PacketConn, err error) func ListenPacket(network, address string) (PacketConn, error) func (*ListenConfig).ListenPacket(ctx context.Context, network, address string) (PacketConn, error) func vendor/golang.org/x/net/nettest.NewLocalPacketListener(network string) (PacketConn, error)
type ParseError (struct) A ParseError is the error type of literal network address parsers. Text string Type string (*T) Error() string *T : error
type Resolver (struct) A Resolver looks up names and numbers. A nil *Resolver is equivalent to a zero Resolver. Dial func(ctx context.Context, network, address string) (Conn, error) PreferGo bool StrictErrors bool (*T) LookupAddr(ctx context.Context, addr string) (names []string, err error) (*T) LookupCNAME(ctx context.Context, host string) (cname string, err error) (*T) LookupHost(ctx context.Context, host string) (addrs []string, err error) (*T) LookupIP(ctx context.Context, network, host string) ([]IP, error) (*T) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, error) (*T) LookupMX(ctx context.Context, name string) ([]*MX, error) (*T) LookupNS(ctx context.Context, name string) ([]*NS, error) (*T) LookupPort(ctx context.Context, network, service string) (port int, err error) (*T) LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*SRV, err error) (*T) LookupTXT(ctx context.Context, name string) ([]string, error) var DefaultResolver *Resolver
type SRV (struct) An SRV represents a single DNS SRV record. Port uint16 Priority uint16 Target string Weight uint16 func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) func (*Resolver).LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*SRV, err error)
type TCPAddr (struct) TCPAddr represents the address of a TCP end point. IP IP Port int Zone string (*T) Network() string (*T) String() string *T : Addr *T : expvar.Var *T : fmt.Stringer func ResolveTCPAddr(network, address string) (*TCPAddr, error) func DialTCP(network string, laddr, raddr *TCPAddr) (*TCPConn, error) func ListenTCP(network string, laddr *TCPAddr) (*TCPListener, error)
type TCPConn (struct) TCPConn is an implementation of the Conn interface for TCP network connections. (*T) Close() error (*T) CloseRead() error (*T) CloseWrite() error (*T) File() (f *os.File, err error) (*T) LocalAddr() Addr (*T) Read(b []byte) (int, error) (*T) ReadFrom(r io.Reader) (int64, error) (*T) RemoteAddr() Addr (*T) SetDeadline(t time.Time) error (*T) SetKeepAlive(keepalive bool) error (*T) SetKeepAlivePeriod(d time.Duration) error (*T) SetLinger(sec int) error (*T) SetNoDelay(noDelay bool) error (*T) SetReadBuffer(bytes int) error (*T) SetReadDeadline(t time.Time) error (*T) SetWriteBuffer(bytes int) error (*T) SetWriteDeadline(t time.Time) error (*T) SyscallConn() (syscall.RawConn, error) (*T) Write(b []byte) (int, error) *T : Conn *T : io.Closer *T : io.ReadCloser *T : io.Reader *T : io.ReaderFrom *T : io.ReadWriteCloser *T : io.ReadWriter *T : io.WriteCloser *T : io.Writer *T : syscall.Conn func DialTCP(network string, laddr, raddr *TCPAddr) (*TCPConn, error) func (*TCPListener).AcceptTCP() (*TCPConn, error)
type TCPListener (struct) TCPListener is a TCP network listener. Clients should typically use variables of type Listener instead of assuming TCP. (*T) Accept() (Conn, error) (*T) AcceptTCP() (*TCPConn, error) (*T) Addr() Addr (*T) Close() error (*T) File() (f *os.File, err error) (*T) SetDeadline(t time.Time) error (*T) SyscallConn() (syscall.RawConn, error) *T : Listener *T : io.Closer *T : syscall.Conn func ListenTCP(network string, laddr *TCPAddr) (*TCPListener, error)
type UDPAddr (struct) UDPAddr represents the address of a UDP end point. IP IP Port int Zone string (*T) Network() string (*T) String() string *T : Addr *T : expvar.Var *T : fmt.Stringer func ResolveUDPAddr(network, address string) (*UDPAddr, error) func (*UDPConn).ReadFromUDP(b []byte) (int, *UDPAddr, error) func (*UDPConn).ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) func DialUDP(network string, laddr, raddr *UDPAddr) (*UDPConn, error) func ListenMulticastUDP(network string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error) func ListenUDP(network string, laddr *UDPAddr) (*UDPConn, error) func (*UDPConn).WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) func (*UDPConn).WriteToUDP(b []byte, addr *UDPAddr) (int, error)
type UDPConn (struct) UDPConn is the implementation of the Conn and PacketConn interfaces for UDP network connections. (*T) Close() error (*T) File() (f *os.File, err error) (*T) LocalAddr() Addr (*T) Read(b []byte) (int, error) (*T) ReadFrom(b []byte) (int, Addr, error) (*T) ReadFromUDP(b []byte) (int, *UDPAddr, error) (*T) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) (*T) RemoteAddr() Addr (*T) SetDeadline(t time.Time) error (*T) SetReadBuffer(bytes int) error (*T) SetReadDeadline(t time.Time) error (*T) SetWriteBuffer(bytes int) error (*T) SetWriteDeadline(t time.Time) error (*T) SyscallConn() (syscall.RawConn, error) (*T) Write(b []byte) (int, error) (*T) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) (*T) WriteTo(b []byte, addr Addr) (int, error) (*T) WriteToUDP(b []byte, addr *UDPAddr) (int, error) *T : Conn *T : PacketConn *T : io.Closer *T : io.ReadCloser *T : io.Reader *T : io.ReadWriteCloser *T : io.ReadWriter *T : io.WriteCloser *T : io.Writer *T : syscall.Conn func DialUDP(network string, laddr, raddr *UDPAddr) (*UDPConn, error) func ListenMulticastUDP(network string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error) func ListenUDP(network string, laddr *UDPAddr) (*UDPConn, error)
type UnixAddr (struct) UnixAddr represents the address of a Unix domain socket end point. Name string Net string (*T) Network() string (*T) String() string *T : Addr *T : expvar.Var *T : fmt.Stringer func ResolveUnixAddr(network, address string) (*UnixAddr, error) func (*UnixConn).ReadFromUnix(b []byte) (int, *UnixAddr, error) func (*UnixConn).ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err error) func DialUnix(network string, laddr, raddr *UnixAddr) (*UnixConn, error) func ListenUnix(network string, laddr *UnixAddr) (*UnixListener, error) func ListenUnixgram(network string, laddr *UnixAddr) (*UnixConn, error) func (*UnixConn).WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err error) func (*UnixConn).WriteToUnix(b []byte, addr *UnixAddr) (int, error)
type UnixConn (struct) UnixConn is an implementation of the Conn interface for connections to Unix domain sockets. (*T) Close() error (*T) CloseRead() error (*T) CloseWrite() error (*T) File() (f *os.File, err error) (*T) LocalAddr() Addr (*T) Read(b []byte) (int, error) (*T) ReadFrom(b []byte) (int, Addr, error) (*T) ReadFromUnix(b []byte) (int, *UnixAddr, error) (*T) ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err error) (*T) RemoteAddr() Addr (*T) SetDeadline(t time.Time) error (*T) SetReadBuffer(bytes int) error (*T) SetReadDeadline(t time.Time) error (*T) SetWriteBuffer(bytes int) error (*T) SetWriteDeadline(t time.Time) error (*T) SyscallConn() (syscall.RawConn, error) (*T) Write(b []byte) (int, error) (*T) WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err error) (*T) WriteTo(b []byte, addr Addr) (int, error) (*T) WriteToUnix(b []byte, addr *UnixAddr) (int, error) *T : Conn *T : PacketConn *T : io.Closer *T : io.ReadCloser *T : io.Reader *T : io.ReadWriteCloser *T : io.ReadWriter *T : io.WriteCloser *T : io.Writer *T : syscall.Conn func DialUnix(network string, laddr, raddr *UnixAddr) (*UnixConn, error) func ListenUnixgram(network string, laddr *UnixAddr) (*UnixConn, error) func (*UnixListener).AcceptUnix() (*UnixConn, error)
type UnixListener (struct) UnixListener is a Unix domain socket listener. Clients should typically use variables of type Listener instead of assuming Unix domain sockets. (*T) Accept() (Conn, error) (*T) AcceptUnix() (*UnixConn, error) (*T) Addr() Addr (*T) Close() error (*T) File() (f *os.File, err error) (*T) SetDeadline(t time.Time) error (*T) SetUnlinkOnClose(unlink bool) (*T) SyscallConn() (syscall.RawConn, error) *T : Listener *T : io.Closer *T : syscall.Conn func ListenUnix(network string, laddr *UnixAddr) (*UnixListener, error)
type UnknownNetworkError string (T) Error() string (T) Temporary() bool (T) Timeout() bool T : Error T : error
Exported Values
func CIDRMask(ones, bits int) IPMask CIDRMask returns an IPMask consisting of 'ones' 1 bits followed by 0s up to a total length of 'bits' bits. For a mask of this form, CIDRMask is the inverse of IPMask.Size.
var DefaultResolver *Resolver DefaultResolver is the resolver used by the package-level Lookup functions and by Dialers without a specified Resolver.
func Dial(network, address string) (Conn, error) Dial connects to the address on the named network. Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and "unixpacket". For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address, or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name. If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007. The functions JoinHostPort and SplitHostPort manipulate a pair of host and port in this form. When using TCP, and the host resolves to multiple IP addresses, Dial will try each IP address in order until one succeeds. Examples: Dial("tcp", "golang.org:http") Dial("tcp", "192.0.2.1:http") Dial("tcp", "198.51.100.1:80") Dial("udp", "[2001:db8::1]:domain") Dial("udp", "[fe80::1%lo0]:53") Dial("tcp", ":80") For IP networks, the network must be "ip", "ip4" or "ip6" followed by a colon and a literal protocol number or a protocol name, and the address has the form "host". The host must be a literal IP address or a literal IPv6 address with zone. It depends on each operating system how the operating system behaves with a non-well known protocol number such as "0" or "255". Examples: Dial("ip4:1", "192.0.2.1") Dial("ip6:ipv6-icmp", "2001:db8::1") Dial("ip6:58", "fe80::1%lo0") For TCP, UDP and IP networks, if the host is empty or a literal unspecified IP address, as in ":80", "0.0.0.0:80" or "[::]:80" for TCP and UDP, "", "0.0.0.0" or "::" for IP, the local system is assumed. For Unix networks, the address must be a file system path.
func DialIP(network string, laddr, raddr *IPAddr) (*IPConn, error) DialIP acts like Dial for IP networks. The network must be an IP network name; see func Dial for details. If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.
func DialTCP(network string, laddr, raddr *TCPAddr) (*TCPConn, error) DialTCP acts like Dial for TCP networks. The network must be a TCP network name; see func Dial for details. If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.
func DialTimeout(network, address string, timeout time.Duration) (Conn, error) DialTimeout acts like Dial but takes a timeout. The timeout includes name resolution, if required. When using TCP, and the host in the address parameter resolves to multiple IP addresses, the timeout is spread over each consecutive dial, such that each is given an appropriate fraction of the time to connect. See func Dial for a description of the network and address parameters.
func DialUDP(network string, laddr, raddr *UDPAddr) (*UDPConn, error) DialUDP acts like Dial for UDP networks. The network must be a UDP network name; see func Dial for details. If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.
func DialUnix(network string, laddr, raddr *UnixAddr) (*UnixConn, error) DialUnix acts like Dial for Unix networks. The network must be a Unix network name; see func Dial for details. If laddr is non-nil, it is used as the local address for the connection.
var ErrWriteToConnected error Various errors contained in OpError.
func FileConn(f *os.File) (c Conn, err error) FileConn returns a copy of the network connection corresponding to the open file f. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.
func FileListener(f *os.File) (ln Listener, err error) FileListener returns a copy of the network listener corresponding to the open file f. It is the caller's responsibility to close ln when finished. Closing ln does not affect f, and closing f does not affect ln.
func FilePacketConn(f *os.File) (c PacketConn, err error) FilePacketConn returns a copy of the packet network connection corresponding to the open file f. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.
const FlagBroadcast Flags = 2 // interface supports broadcast access capability
const FlagLoopback Flags = 4 // interface is a loopback interface
const FlagMulticast Flags = 16 // interface supports multicast access capability
const FlagPointToPoint Flags = 8 // interface belongs to a point-to-point link
const FlagUp Flags = 1 // interface is up
func InterfaceAddrs() ([]Addr, error) InterfaceAddrs returns a list of the system's unicast interface addresses. The returned list does not identify the associated interface; use Interfaces and Interface.Addrs for more detail.
func InterfaceByIndex(index int) (*Interface, error) InterfaceByIndex returns the interface specified by index. On Solaris, it returns one of the logical network interfaces sharing the logical data link; for more precision use InterfaceByName.
func InterfaceByName(name string) (*Interface, error) InterfaceByName returns the interface specified by name.
func Interfaces() ([]Interface, error) Interfaces returns a list of the system's network interfaces.
func IPv4(a, b, c, d byte) IP IPv4 returns the IP address (in 16-byte form) of the IPv4 address a.b.c.d.
var IPv4allrouter IP // all routers Well-known IPv4 addresses
var IPv4allsys IP // all systems Well-known IPv4 addresses
var IPv4bcast IP // limited broadcast Well-known IPv4 addresses
const IPv4len = 4 IP address lengths (bytes).
func IPv4Mask(a, b, c, d byte) IPMask IPv4Mask returns the IP mask (in 4-byte form) of the IPv4 mask a.b.c.d.
var IPv4zero IP // all zeros Well-known IPv4 addresses
var IPv6interfacelocalallnodes IP Well-known IPv6 addresses
const IPv6len = 16 IP address lengths (bytes).
var IPv6linklocalallnodes IP Well-known IPv6 addresses
var IPv6linklocalallrouters IP Well-known IPv6 addresses
var IPv6loopback IP Well-known IPv6 addresses
var IPv6unspecified IP Well-known IPv6 addresses
var IPv6zero IP Well-known IPv6 addresses
func JoinHostPort(host, port string) string JoinHostPort combines host and port into a network address of the form "host:port". If host contains a colon, as found in literal IPv6 addresses, then JoinHostPort returns "[host]:port". See func Dial for a description of the host and port parameters.
func Listen(network, address string) (Listener, error) Listen announces on the local network address. The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket". For TCP networks, if the host in the address parameter is empty or a literal unspecified IP address, Listen listens on all available unicast and anycast IP addresses of the local system. To only use IPv4, use network "tcp4". The address can use a host name, but this is not recommended, because it will create a listener for at most one of the host's IP addresses. If the port in the address parameter is empty or "0", as in "127.0.0.1:" or "[::1]:0", a port number is automatically chosen. The Addr method of Listener can be used to discover the chosen port. See func Dial for a description of the network and address parameters.
func ListenIP(network string, laddr *IPAddr) (*IPConn, error) ListenIP acts like ListenPacket for IP networks. The network must be an IP network name; see func Dial for details. If the IP field of laddr is nil or an unspecified IP address, ListenIP listens on all available IP addresses of the local system except multicast IP addresses.
func ListenMulticastUDP(network string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error) ListenMulticastUDP acts like ListenPacket for UDP networks but takes a group address on a specific network interface. The network must be a UDP network name; see func Dial for details. ListenMulticastUDP listens on all available IP addresses of the local system including the group, multicast IP address. If ifi is nil, ListenMulticastUDP uses the system-assigned multicast interface, although this is not recommended because the assignment depends on platforms and sometimes it might require routing configuration. If the Port field of gaddr is 0, a port number is automatically chosen. ListenMulticastUDP is just for convenience of simple, small applications. There are golang.org/x/net/ipv4 and golang.org/x/net/ipv6 packages for general purpose uses.
func ListenPacket(network, address string) (PacketConn, error) ListenPacket announces on the local network address. The network must be "udp", "udp4", "udp6", "unixgram", or an IP transport. The IP transports are "ip", "ip4", or "ip6" followed by a colon and a literal protocol number or a protocol name, as in "ip:1" or "ip:icmp". For UDP and IP networks, if the host in the address parameter is empty or a literal unspecified IP address, ListenPacket listens on all available IP addresses of the local system except multicast IP addresses. To only use IPv4, use network "udp4" or "ip4:proto". The address can use a host name, but this is not recommended, because it will create a listener for at most one of the host's IP addresses. If the port in the address parameter is empty or "0", as in "127.0.0.1:" or "[::1]:0", a port number is automatically chosen. The LocalAddr method of PacketConn can be used to discover the chosen port. See func Dial for a description of the network and address parameters.
func ListenTCP(network string, laddr *TCPAddr) (*TCPListener, error) ListenTCP acts like Listen for TCP networks. The network must be a TCP network name; see func Dial for details. If the IP field of laddr is nil or an unspecified IP address, ListenTCP listens on all available unicast and anycast IP addresses of the local system. If the Port field of laddr is 0, a port number is automatically chosen.
func ListenUDP(network string, laddr *UDPAddr) (*UDPConn, error) ListenUDP acts like ListenPacket for UDP networks. The network must be a UDP network name; see func Dial for details. If the IP field of laddr is nil or an unspecified IP address, ListenUDP listens on all available IP addresses of the local system except multicast IP addresses. If the Port field of laddr is 0, a port number is automatically chosen.
func ListenUnix(network string, laddr *UnixAddr) (*UnixListener, error) ListenUnix acts like Listen for Unix networks. The network must be "unix" or "unixpacket".
func ListenUnixgram(network string, laddr *UnixAddr) (*UnixConn, error) ListenUnixgram acts like ListenPacket for Unix networks. The network must be "unixgram".
func LookupAddr(addr string) (names []string, err error) LookupAddr performs a reverse lookup for the given address, returning a list of names mapping to that address. When using the host C library resolver, at most one result will be returned. To bypass the host resolver, use a custom Resolver.
func LookupCNAME(host string) (cname string, err error) LookupCNAME returns the canonical name for the given host. Callers that do not care about the canonical name can call LookupHost or LookupIP directly; both take care of resolving the canonical name as part of the lookup. A canonical name is the final name after following zero or more CNAME records. LookupCNAME does not return an error if host does not contain DNS "CNAME" records, as long as host resolves to address records.
func LookupHost(host string) (addrs []string, err error) LookupHost looks up the given host using the local resolver. It returns a slice of that host's addresses.
func LookupIP(host string) ([]IP, error) LookupIP looks up host using the local resolver. It returns a slice of that host's IPv4 and IPv6 addresses.
func LookupMX(name string) ([]*MX, error) LookupMX returns the DNS MX records for the given domain name sorted by preference.
func LookupNS(name string) ([]*NS, error) LookupNS returns the DNS NS records for the given domain name.
func LookupPort(network, service string) (port int, err error) LookupPort looks up the port for the given network and service.
func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) LookupSRV tries to resolve an SRV query of the given service, protocol, and domain name. The proto is "tcp" or "udp". The returned records are sorted by priority and randomized by weight within a priority. LookupSRV constructs the DNS name to look up following RFC 2782. That is, it looks up _service._proto.name. To accommodate services publishing SRV records under non-standard names, if both service and proto are empty strings, LookupSRV looks up name directly.
func LookupTXT(name string) ([]string, error) LookupTXT returns the DNS TXT records for the given domain name.
func ParseCIDR(s string) (IP, *IPNet, error) ParseCIDR parses s as a CIDR notation IP address and prefix length, like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291. It returns the IP address and the network implied by the IP and prefix length. For example, ParseCIDR("192.0.2.1/24") returns the IP address 192.0.2.1 and the network 192.0.2.0/24.
func ParseIP(s string) IP ParseIP parses s as an IP address, returning the result. The string s can be in IPv4 dotted decimal ("192.0.2.1"), IPv6 ("2001:db8::68"), or IPv4-mapped IPv6 ("::ffff:192.0.2.1") form. If s is not a valid textual representation of an IP address, ParseIP returns nil.
func ParseMAC(s string) (hw HardwareAddr, err error) ParseMAC parses s as an IEEE 802 MAC-48, EUI-48, EUI-64, or a 20-octet IP over InfiniBand link-layer address using one of the following formats: 00:00:5e:00:53:01 02:00:5e:10:00:00:00:01 00:00:00:00:fe:80:00:00:00:00:00:00:02:00:5e:10:00:00:00:01 00-00-5e-00-53-01 02-00-5e-10-00-00-00-01 00-00-00-00-fe-80-00-00-00-00-00-00-02-00-5e-10-00-00-00-01 0000.5e00.5301 0200.5e10.0000.0001 0000.0000.fe80.0000.0000.0000.0200.5e10.0000.0001
func Pipe() (Conn, Conn) Pipe creates a synchronous, in-memory, full duplex network connection; both ends implement the Conn interface. Reads on one end are matched with writes on the other, copying data directly between the two; there is no internal buffering.
func ResolveIPAddr(network, address string) (*IPAddr, error) ResolveIPAddr returns an address of IP end point. The network must be an IP network name. If the host in the address parameter is not a literal IP address, ResolveIPAddr resolves the address to an address of IP end point. Otherwise, it parses the address as a literal IP address. The address parameter can use a host name, but this is not recommended, because it will return at most one of the host name's IP addresses. See func Dial for a description of the network and address parameters.
func ResolveTCPAddr(network, address string) (*TCPAddr, error) ResolveTCPAddr returns an address of TCP end point. The network must be a TCP network name. If the host in the address parameter is not a literal IP address or the port is not a literal port number, ResolveTCPAddr resolves the address to an address of TCP end point. Otherwise, it parses the address as a pair of literal IP address and port number. The address parameter can use a host name, but this is not recommended, because it will return at most one of the host name's IP addresses. See func Dial for a description of the network and address parameters.
func ResolveUDPAddr(network, address string) (*UDPAddr, error) ResolveUDPAddr returns an address of UDP end point. The network must be a UDP network name. If the host in the address parameter is not a literal IP address or the port is not a literal port number, ResolveUDPAddr resolves the address to an address of UDP end point. Otherwise, it parses the address as a pair of literal IP address and port number. The address parameter can use a host name, but this is not recommended, because it will return at most one of the host name's IP addresses. See func Dial for a description of the network and address parameters.
func ResolveUnixAddr(network, address string) (*UnixAddr, error) ResolveUnixAddr returns an address of Unix domain socket end point. The network must be a Unix network name. See func Dial for a description of the network and address parameters.
func SplitHostPort(hostport string) (host, port string, err error) SplitHostPort splits a network address of the form "host:port", "host%zone:port", "[host]:port" or "[host%zone]:port" into host or host%zone and port. A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80". See func Dial for a description of the hostport parameter, and host and port results.