Documentation ¶
Overview ¶
Package net provides a portable interface to Unix networks sockets, including TCP/IP, UDP, domain name resolution, and Unix domain sockets.
Index ¶
- Constants
- Variables
- func JoinHostPort(host, port string) string
- func LookupAddr(addr string) (name []string, err os.Error)
- func LookupCNAME(name string) (cname string, err os.Error)
- func LookupHost(host string) (addrs []string, err os.Error)
- func LookupPort(network, service string) (port int, err os.Error)
- func ParseCIDR(s string) (ip IP, mask IPMask, err os.Error)
- func Pipe() (Conn, Conn)
- func SplitHostPort(hostport string) (host, port string, err os.Error)
- type Addr
- type AddrError
- type Conn
- type DNSConfigError
- type DNSError
- type Error
- type HardwareAddr
- type IP
- func (ip IP) DefaultMask() IPMask
- func (ip IP) Equal(x IP) bool
- func (ip IP) IsGlobalUnicast() bool
- func (ip IP) IsInterfaceLocalMulticast() bool
- func (ip IP) IsLinkLocalMulticast() bool
- func (ip IP) IsLinkLocalUnicast() bool
- func (ip IP) IsLoopback() bool
- func (ip IP) IsMulticast() bool
- func (ip IP) IsUnspecified() bool
- func (ip IP) Mask(mask IPMask) IP
- func (ip IP) String() string
- func (ip IP) To16() IP
- func (ip IP) To4() IP
- type IPAddr
- type IPConn
- func (c *IPConn) BindToDevice(device string) os.Error
- func (c *IPConn) Close() os.Error
- func (c *IPConn) LocalAddr() Addr
- func (c *IPConn) Read(b []byte) (n int, err os.Error)
- func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error)
- func (c *IPConn) ReadFromIP(b []byte) (n int, addr *IPAddr, err os.Error)
- func (c *IPConn) RemoteAddr() Addr
- func (c *IPConn) SetReadBuffer(bytes int) os.Error
- func (c *IPConn) SetReadTimeout(nsec int64) os.Error
- func (c *IPConn) SetTimeout(nsec int64) os.Error
- func (c *IPConn) SetWriteBuffer(bytes int) os.Error
- func (c *IPConn) SetWriteTimeout(nsec int64) os.Error
- func (c *IPConn) Write(b []byte) (n int, err os.Error)
- func (c *IPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error)
- func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (n int, err os.Error)
- type IPMask
- type Interface
- type InvalidAddrError
- type InvalidConnError
- type Listener
- type MX
- type OpError
- type PacketConn
- type ParseError
- type SRV
- type TCPAddr
- type TCPConn
- func (c *TCPConn) Close() os.Error
- func (c *TCPConn) File() (f *os.File, err os.Error)
- func (c *TCPConn) LocalAddr() Addr
- func (c *TCPConn) Read(b []byte) (n int, err os.Error)
- func (c *TCPConn) ReadFrom(r io.Reader) (int64, os.Error)
- func (c *TCPConn) RemoteAddr() Addr
- func (c *TCPConn) SetKeepAlive(keepalive bool) os.Error
- func (c *TCPConn) SetLinger(sec int) os.Error
- func (c *TCPConn) SetNoDelay(noDelay bool) os.Error
- func (c *TCPConn) SetReadBuffer(bytes int) os.Error
- func (c *TCPConn) SetReadTimeout(nsec int64) os.Error
- func (c *TCPConn) SetTimeout(nsec int64) os.Error
- func (c *TCPConn) SetWriteBuffer(bytes int) os.Error
- func (c *TCPConn) SetWriteTimeout(nsec int64) os.Error
- func (c *TCPConn) Write(b []byte) (n int, err os.Error)
- type TCPListener
- type UDPAddr
- type UDPConn
- func (c *UDPConn) BindToDevice(device string) os.Error
- func (c *UDPConn) Close() os.Error
- func (c *UDPConn) File() (f *os.File, err os.Error)
- func (c *UDPConn) JoinGroup(addr IP) os.Error
- func (c *UDPConn) LeaveGroup(addr IP) os.Error
- func (c *UDPConn) LocalAddr() Addr
- func (c *UDPConn) Read(b []byte) (n int, err os.Error)
- func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error)
- func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error)
- func (c *UDPConn) RemoteAddr() Addr
- func (c *UDPConn) SetReadBuffer(bytes int) os.Error
- func (c *UDPConn) SetReadTimeout(nsec int64) os.Error
- func (c *UDPConn) SetTimeout(nsec int64) os.Error
- func (c *UDPConn) SetWriteBuffer(bytes int) os.Error
- func (c *UDPConn) SetWriteTimeout(nsec int64) os.Error
- func (c *UDPConn) Write(b []byte) (n int, err os.Error)
- func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error)
- func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error)
- type UnixAddr
- type UnixConn
- func (c *UnixConn) Close() os.Error
- func (c *UnixConn) File() (f *os.File, err os.Error)
- func (c *UnixConn) LocalAddr() Addr
- func (c *UnixConn) Read(b []byte) (n int, err os.Error)
- func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error)
- func (c *UnixConn) ReadFromUnix(b []byte) (n int, addr *UnixAddr, err os.Error)
- func (c *UnixConn) ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err os.Error)
- func (c *UnixConn) RemoteAddr() Addr
- func (c *UnixConn) SetReadBuffer(bytes int) os.Error
- func (c *UnixConn) SetReadTimeout(nsec int64) os.Error
- func (c *UnixConn) SetTimeout(nsec int64) os.Error
- func (c *UnixConn) SetWriteBuffer(bytes int) os.Error
- func (c *UnixConn) SetWriteTimeout(nsec int64) os.Error
- func (c *UnixConn) Write(b []byte) (n int, err os.Error)
- func (c *UnixConn) WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err os.Error)
- func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err os.Error)
- func (c *UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (n int, err os.Error)
- type UnixListener
- type UnknownNetworkError
- type UnknownSocketError
Constants ¶
const ( IPv4len = 4 IPv6len = 16 )
IP address lengths (bytes).
Variables ¶
var ( IPv4bcast = IPv4(255, 255, 255, 255) // broadcast IPv4allsys = IPv4(224, 0, 0, 1) // all systems IPv4allrouter = IPv4(224, 0, 0, 2) // all routers IPv4zero = IPv4(0, 0, 0, 0) // all zeros )
Well-known IPv4 addresses
var ( IPv6zero = IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} IPv6unspecified = IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} IPv6loopback = IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} IPv6interfacelocalallnodes = IP{0xff, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01} IPv6linklocalallnodes = IP{0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01} IPv6linklocalallrouters = IP{0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02} )
Well-known IPv6 addresses
Functions ¶
func JoinHostPort ¶
JoinHostPort combines host and port into a network address of the form "host:port" or, if host contains a colon, "[host]:port".
func LookupAddr ¶
LookupAddr performs a reverse lookup for the given address, returning a list of names mapping to that address.
func LookupCNAME ¶
LookupCNAME returns the canonical DNS host for the given name. 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.
func LookupHost ¶
LookupHost looks up the given host using the local resolver. It returns an array of that host's addresses.
func LookupPort ¶
LookupPort looks up the port for the given network and service.
func ParseCIDR ¶
ParseCIDR parses s as a CIDR notation IP address and mask, like "192.168.100.1/24", "2001:DB8::/48", as defined in RFC 4632 and RFC 4291.
Types ¶
type Addr ¶
type Addr interface { Network() string // name of the network String() string // string form of address }
Addr represents a network end point address.
func InterfaceAddrs ¶
InterfaceAddrs returns a list of the system's network interface addresses.
type Conn ¶
type Conn interface { // Read reads data from the connection. // Read can be made to time out and return a net.Error with Timeout() == true // after a fixed time limit; see SetTimeout and SetReadTimeout. Read(b []byte) (n int, err os.Error) // Write writes data to the connection. // Write can be made to time out and return a net.Error with Timeout() == true // after a fixed time limit; see SetTimeout and SetWriteTimeout. Write(b []byte) (n int, err os.Error) // Close closes the connection. Close() os.Error // LocalAddr returns the local network address. LocalAddr() Addr // RemoteAddr returns the remote network address. RemoteAddr() Addr // SetTimeout sets the read and write deadlines associated // with the connection. SetTimeout(nsec int64) os.Error // SetReadTimeout sets the time (in nanoseconds) that // Read will wait for data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. SetReadTimeout(nsec int64) os.Error // SetWriteTimeout sets the time (in nanoseconds) that // Write will wait to send its data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. SetWriteTimeout(nsec int64) os.Error }
Conn is a generic stream-oriented network connection.
func Dial ¶
Dial connects to the address addr on the network net.
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" and "unixgram".
For IP networks, addresses have the form host:port. If host is a literal IPv6 address, it must be enclosed in square brackets. The functions JoinHostPort and SplitHostPort manipulate addresses in this form.
Examples:
Dial("tcp", "12.34.56.78:80") Dial("tcp", "google.com:80") Dial("tcp", "[de:ad:be:ef::ca:fe]:80")
type DNSConfigError ¶
func (*DNSConfigError) String ¶
func (e *DNSConfigError) String() string
func (*DNSConfigError) Temporary ¶
func (e *DNSConfigError) Temporary() bool
func (*DNSConfigError) Timeout ¶
func (e *DNSConfigError) Timeout() bool
type DNSError ¶
type DNSError struct { Error string // description of the error Name string // name looked for Server string // server used IsTimeout bool }
DNSError represents a DNS lookup error.
type Error ¶
type Error interface { os.Error Timeout() bool // Is the error a timeout? Temporary() bool // Is the error temporary? }
An Error represents a network error.
type HardwareAddr ¶
type HardwareAddr []byte
A HardwareAddr represents a physical hardware address.
func (HardwareAddr) String ¶
func (a HardwareAddr) String() string
type IP ¶
type IP []byte
An IP is a single IP address, an array of bytes. Functions in this package accept either 4-byte (IP v4) or 16-byte (IP v6) arrays as input. Unless otherwise specified, functions in this package always return IP addresses in 16-byte form using the canonical embedding.
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 array: a 16-byte array can still be an IPv4 address.
func LookupIP ¶
LookupIP looks up host using the local resolver. It returns an array of that host's IPv4 and IPv6 addresses.
func ParseIP ¶
ParseIP parses s as an IP address, returning the result. The string s can be in dotted decimal ("74.125.19.99") or IPv6 ("2001:4860:0:2001::68") form. If s is not a valid textual representation of an IP address, ParseIP returns nil.
func (IP) DefaultMask ¶
DefaultMask returns the default IP mask for the IP address ip. Only IPv4 addresses have default masks; DefaultMask returns nil if ip is not a valid IPv4 address.
func (IP) Equal ¶
Equal returns true if ip and x are the same IP address. An IPv4 address and that same address in IPv6 form are considered to be equal.
func (IP) IsGlobalUnicast ¶
IsGlobalUnicast returns true if ip is a global unicast address.
func (IP) IsInterfaceLocalMulticast ¶
IsInterfaceLinkLocalMulticast returns true if ip is an interface-local multicast address.
func (IP) IsLinkLocalMulticast ¶
IsLinkLocalMulticast returns true if ip is a link-local multicast address.
func (IP) IsLinkLocalUnicast ¶
IsLinkLocalUnicast returns true if ip is a link-local unicast address.
func (IP) IsLoopback ¶
IsLoopback returns true if ip is a loopback address.
func (IP) IsMulticast ¶
IsMulticast returns true if ip is a multicast address.
func (IP) IsUnspecified ¶
IsUnspecified returns true if ip is an unspecified address.
func (IP) String ¶
String returns the string form of the IP address ip. If the address is an IPv4 address, the string representation is dotted decimal ("74.125.19.99"). Otherwise the representation is IPv6 ("2001:4860:0:2001::68").
type IPAddr ¶
type IPAddr struct {
IP IP
}
IPAddr represents the address of a IP end point.
func ResolveIPAddr ¶
ResolveIPAddr parses addr as a IP address and resolves domain names to numeric addresses on the network net, which must be "ip", "ip4" or "ip6". A literal IPv6 host address must be enclosed in square brackets, as in "[::]".
type IPConn ¶
type IPConn struct {
// contains filtered or unexported fields
}
IPConn is the implementation of the Conn and PacketConn interfaces for IP network connections.
func DialIP ¶
DialIP connects to the remote address raddr on the network net, which must be "ip", "ip4", or "ip6".
func ListenIP ¶
ListenIP listens for incoming IP packets addressed to the local address laddr. The returned connection c's ReadFrom and WriteTo methods can be used to receive and send IP packets with per-packet addressing.
func (*IPConn) BindToDevice ¶
BindToDevice binds an IPConn to a network interface.
func (*IPConn) ReadFromIP ¶
ReadFromIP reads a IP packet from c, copying the payload into b. It returns the number of bytes copied into b and the return address that was on the packet.
ReadFromIP can be made to time out and return an error with Timeout() == true after a fixed time limit; see SetTimeout and SetReadTimeout.
func (*IPConn) RemoteAddr ¶
RemoteAddr returns the remote network address, a *IPAddr.
func (*IPConn) SetReadBuffer ¶
SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.
func (*IPConn) SetReadTimeout ¶
SetReadTimeout implements the net.Conn SetReadTimeout method.
func (*IPConn) SetTimeout ¶
SetTimeout implements the net.Conn SetTimeout method.
func (*IPConn) SetWriteBuffer ¶
SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.
func (*IPConn) SetWriteTimeout ¶
SetWriteTimeout implements the net.Conn SetWriteTimeout method.
type IPMask ¶
type IPMask []byte
An IP mask is an IP address.
type Interface ¶
type Interface struct { Index int // positive integer that starts at one, zero is never used MTU int // maximum transmission unit Name string // e.g., "en0", "lo0", "eth0.100" HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form // contains filtered or unexported fields }
Interface represents a mapping between network interface name and index. It also represents network interface facility information.
func InterfaceByIndex ¶
InterfaceByIndex returns the interface specified by index.
func InterfaceByName ¶
InterfaceByName returns the interface specified by name.
func Interfaces ¶
Interfaces returns a list of the systems's network interfaces.
func (*Interface) CanBroadcast ¶
CanBroadcast returns true if ifi supports a broadcast access capability.
func (*Interface) CanMulticast ¶
CanMulticast returns true if ifi supports a multicast access capability.
func (*Interface) IsLoopback ¶
IsLoopback returns true if ifi is a loopback interface.
func (*Interface) IsPointToPoint ¶
IsPointToPoint returns true if ifi belongs to a point-to-point link.
type InvalidAddrError ¶
type InvalidAddrError string
func (InvalidAddrError) String ¶
func (e InvalidAddrError) String() string
func (InvalidAddrError) Temporary ¶
func (e InvalidAddrError) Temporary() bool
func (InvalidAddrError) Timeout ¶
func (e InvalidAddrError) Timeout() bool
type InvalidConnError ¶
type InvalidConnError struct{}
func (*InvalidConnError) String ¶
func (e *InvalidConnError) String() string
func (*InvalidConnError) Temporary ¶
func (e *InvalidConnError) Temporary() bool
func (*InvalidConnError) Timeout ¶
func (e *InvalidConnError) Timeout() bool
type Listener ¶
type Listener interface { // Accept waits for and returns the next connection to the listener. Accept() (c Conn, err os.Error) // Close closes the listener. Close() os.Error // Addr returns the listener's network address. Addr() Addr }
A Listener is a generic network listener for stream-oriented protocols.
func FileListener ¶
FileListener returns a copy of the network listener corresponding to the open file f. It is the caller's responsibility to close l when finished. Closing c does not affect l, and closing l does not affect c.
type PacketConn ¶
type PacketConn interface { // ReadFrom reads a packet from the connection, // copying the payload into b. It returns the number of // bytes copied into b and the return address that // was on the packet. // ReadFrom can be made to time out and return // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetReadTimeout. ReadFrom(b []byte) (n int, addr Addr, err os.Error) // WriteTo writes a packet with payload b to addr. // WriteTo can be made to time out and return // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. WriteTo(b []byte, addr Addr) (n int, err os.Error) // Close closes the connection. Close() os.Error // LocalAddr returns the local network address. LocalAddr() Addr // SetTimeout sets the read and write deadlines associated // with the connection. SetTimeout(nsec int64) os.Error // SetReadTimeout sets the time (in nanoseconds) that // Read will wait for data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. SetReadTimeout(nsec int64) os.Error // SetWriteTimeout sets the time (in nanoseconds) that // Write will wait to send its data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. SetWriteTimeout(nsec int64) os.Error }
PacketConn is a generic packet-oriented network connection.
func FilePacketConn ¶
func FilePacketConn(f *os.File) (c PacketConn, err os.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.
func ListenPacket ¶
func ListenPacket(net, laddr string) (c PacketConn, err os.Error)
ListenPacket announces on the local network address laddr. The network string net must be a packet-oriented network: "udp", "udp4", "udp6", or "unixgram".
type ParseError ¶
A ParseError represents a malformed text string and the type of string that was expected.
func (*ParseError) String ¶
func (e *ParseError) String() string
type SRV ¶
An SRV represents a single DNS SRV record.
func LookupSRV ¶
LookupSRV tries to resolve an SRV query of the given service, protocol, and domain name, as specified in RFC 2782. In most cases the proto argument can be the same as the corresponding Addr.Network(). The returned records are sorted by priority and randomized by weight within a priority.
type TCPAddr ¶
TCPAddr represents the address of a TCP end point.
func ResolveTCPAddr ¶
ResolveTCPAddr parses addr as a TCP address of the form host:port and resolves domain names or port names to numeric addresses on the network net, which must be "tcp", "tcp4" or "tcp6". A literal IPv6 host address must be enclosed in square brackets, as in "[::]:80".
type TCPConn ¶
type TCPConn struct {
// contains filtered or unexported fields
}
TCPConn is an implementation of the Conn interface for TCP network connections.
func DialTCP ¶
DialTCP connects to the remote address raddr on the network net, which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used as the local address for the connection.
func (*TCPConn) File ¶
File returns a copy of the underlying os.File, set to blocking mode. 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 (*TCPConn) RemoteAddr ¶
RemoteAddr returns the remote network address, a *TCPAddr.
func (*TCPConn) SetKeepAlive ¶
SetKeepAlive sets whether the operating system should send keepalive messages on the connection.
func (*TCPConn) SetLinger ¶
SetLinger sets the behavior of Close() on a connection which still has data waiting to be sent or to be acknowledged.
If sec < 0 (the default), Close returns immediately and the operating system finishes sending the data in the background.
If sec == 0, Close returns immediately and the operating system discards any unsent or unacknowledged data.
If sec > 0, Close blocks for at most sec seconds waiting for data to be sent and acknowledged.
func (*TCPConn) SetNoDelay ¶
SetNoDelay controls whether the operating system should delay packet transmission in hopes of sending fewer packets (Nagle's algorithm). The default is true (no delay), meaning that data is sent as soon as possible after a Write.
func (*TCPConn) SetReadBuffer ¶
SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.
func (*TCPConn) SetReadTimeout ¶
SetReadTimeout implements the net.Conn SetReadTimeout method.
func (*TCPConn) SetTimeout ¶
SetTimeout implements the net.Conn SetTimeout method.
func (*TCPConn) SetWriteBuffer ¶
SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.
func (*TCPConn) SetWriteTimeout ¶
SetWriteTimeout implements the net.Conn SetWriteTimeout method.
type TCPListener ¶
type TCPListener struct {
// contains filtered or unexported fields
}
TCPListener is a TCP network listener. Clients should typically use variables of type Listener instead of assuming TCP.
func ListenTCP ¶
func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err os.Error)
ListenTCP announces on the TCP address laddr and returns a TCP listener. Net must be "tcp", "tcp4", or "tcp6". If laddr has a port of 0, it means to listen on some available port. The caller can use l.Addr() to retrieve the chosen address.
func (*TCPListener) Accept ¶
func (l *TCPListener) Accept() (c Conn, err os.Error)
Accept implements the Accept method in the Listener interface; it waits for the next call and returns a generic Conn.
func (*TCPListener) AcceptTCP ¶
func (l *TCPListener) AcceptTCP() (c *TCPConn, err os.Error)
AcceptTCP accepts the next incoming call and returns the new connection and the remote address.
func (*TCPListener) Addr ¶
func (l *TCPListener) Addr() Addr
Addr returns the listener's network address, a *TCPAddr.
func (*TCPListener) Close ¶
func (l *TCPListener) Close() os.Error
Close stops listening on the TCP address. Already Accepted connections are not closed.
type UDPAddr ¶
UDPAddr represents the address of a UDP end point.
func ResolveUDPAddr ¶
ResolveUDPAddr parses addr as a UDP address of the form host:port and resolves domain names or port names to numeric addresses on the network net, which must be "udp", "udp4" or "udp6". A literal IPv6 host address must be enclosed in square brackets, as in "[::]:80".
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn is the implementation of the Conn and PacketConn interfaces for UDP network connections.
func DialUDP ¶
DialUDP connects to the remote address raddr on the network net, which must be "udp", "udp4", or "udp6". If laddr is not nil, it is used as the local address for the connection.
func ListenUDP ¶
ListenUDP listens for incoming UDP packets addressed to the local address laddr. The returned connection c's ReadFrom and WriteTo methods can be used to receive and send UDP packets with per-packet addressing.
func ListenUnixgram ¶
ListenUnixgram listens for incoming Unix datagram packets addressed to the local address laddr. The returned connection c's ReadFrom and WriteTo methods can be used to receive and send UDP packets with per-packet addressing. The network net must be "unixgram".
func (*UDPConn) BindToDevice ¶
BindToDevice binds a UDPConn to a network interface.
func (*UDPConn) File ¶
File returns a copy of the underlying os.File, set to blocking mode. 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 (*UDPConn) JoinGroup ¶
JoinGroup joins the IPv4 multicast group named by addr. The UDPConn must use the "udp4" network.
func (*UDPConn) LeaveGroup ¶
LeaveGroup exits the IPv4 multicast group named by addr.
func (*UDPConn) ReadFromUDP ¶
ReadFromUDP reads a UDP packet from c, copying the payload into b. It returns the number of bytes copied into b and the return address that was on the packet.
ReadFromUDP can be made to time out and return an error with Timeout() == true after a fixed time limit; see SetTimeout and SetReadTimeout.
func (*UDPConn) RemoteAddr ¶
RemoteAddr returns the remote network address, a *UDPAddr.
func (*UDPConn) SetReadBuffer ¶
SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.
func (*UDPConn) SetReadTimeout ¶
SetReadTimeout implements the net.Conn SetReadTimeout method.
func (*UDPConn) SetTimeout ¶
SetTimeout implements the net.Conn SetTimeout method.
func (*UDPConn) SetWriteBuffer ¶
SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.
func (*UDPConn) SetWriteTimeout ¶
SetWriteTimeout implements the net.Conn SetWriteTimeout method.
func (*UDPConn) WriteToUDP ¶
WriteToUDP writes a UDP packet to addr via c, copying the payload from b.
WriteToUDP can be made to time out and return an error with Timeout() == true after a fixed time limit; see SetTimeout and SetWriteTimeout. On packet-oriented connections, write timeouts are rare.
type UnixAddr ¶
UnixAddr represents the address of a Unix domain socket end point.
func ResolveUnixAddr ¶
ResolveUnixAddr parses addr as a Unix domain socket address. The string net gives the network name, "unix", "unixgram" or "unixpacket".
type UnixConn ¶
type UnixConn struct {
// contains filtered or unexported fields
}
UnixConn is an implementation of the Conn interface for connections to Unix domain sockets.
func DialUnix ¶
DialUnix connects to the remote address raddr on the network net, which must be "unix" or "unixgram". If laddr is not nil, it is used as the local address for the connection.
func (*UnixConn) File ¶
File returns a copy of the underlying os.File, set to blocking mode. 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 (*UnixConn) LocalAddr ¶
LocalAddr returns the local network address, a *UnixAddr. Unlike in other protocols, LocalAddr is usually nil for dialed connections.
func (*UnixConn) ReadFromUnix ¶
ReadFromUnix reads a packet from c, copying the payload into b. It returns the number of bytes copied into b and the return address that was on the packet.
ReadFromUnix can be made to time out and return an error with Timeout() == true after a fixed time limit; see SetTimeout and SetReadTimeout.
func (*UnixConn) ReadMsgUnix ¶
func (*UnixConn) RemoteAddr ¶
RemoteAddr returns the remote network address, a *UnixAddr. Unlike in other protocols, RemoteAddr is usually nil for connections accepted by a listener.
func (*UnixConn) SetReadBuffer ¶
SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.
func (*UnixConn) SetReadTimeout ¶
SetReadTimeout implements the net.Conn SetReadTimeout method.
func (*UnixConn) SetTimeout ¶
SetTimeout implements the net.Conn SetTimeout method.
func (*UnixConn) SetWriteBuffer ¶
SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.
func (*UnixConn) SetWriteTimeout ¶
SetWriteTimeout implements the net.Conn SetWriteTimeout method.
func (*UnixConn) WriteMsgUnix ¶
func (*UnixConn) WriteToUnix ¶
WriteToUnix writes a packet to addr via c, copying the payload from b.
WriteToUnix can be made to time out and return an error with Timeout() == true after a fixed time limit; see SetTimeout and SetWriteTimeout. On packet-oriented connections, write timeouts are rare.
type UnixListener ¶
type UnixListener struct {
// contains filtered or unexported fields
}
UnixListener is a Unix domain socket listener. Clients should typically use variables of type Listener instead of assuming Unix domain sockets.
func ListenUnix ¶
func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err os.Error)
ListenUnix announces on the Unix domain socket laddr and returns a Unix listener. Net must be "unix" (stream sockets).
func (*UnixListener) Accept ¶
func (l *UnixListener) Accept() (c Conn, err os.Error)
Accept implements the Accept method in the Listener interface; it waits for the next call and returns a generic Conn.
func (*UnixListener) AcceptUnix ¶
func (l *UnixListener) AcceptUnix() (c *UnixConn, err os.Error)
AcceptUnix accepts the next incoming call and returns the new connection and the remote address.
func (*UnixListener) Addr ¶
func (l *UnixListener) Addr() Addr
Addr returns the listener's network address.
func (*UnixListener) Close ¶
func (l *UnixListener) Close() os.Error
Close stops listening on the Unix address. Already accepted connections are not closed.
type UnknownNetworkError ¶
type UnknownNetworkError string
func (UnknownNetworkError) String ¶
func (e UnknownNetworkError) String() string
func (UnknownNetworkError) Temporary ¶
func (e UnknownNetworkError) Temporary() bool
func (UnknownNetworkError) Timeout ¶
func (e UnknownNetworkError) Timeout() bool
type UnknownSocketError ¶
type UnknownSocketError struct {
// contains filtered or unexported fields
}
func (*UnknownSocketError) String ¶
func (e *UnknownSocketError) String() string
Source Files ¶
- cgo_bsd.go
- cgo_linux.go
- cgo_stub.go
- cgo_unix.go
- dial.go
- dnsclient.go
- dnsconfig.go
- dnsmsg.go
- fd.go
- fd_linux.go
- file.go
- hosts.go
- interface.go
- interface_bsd.go
- interface_linux.go
- interface_stub.go
- ip.go
- iprawsock.go
- ipsock.go
- lookup.go
- net.go
- newpollserver.go
- parse.go
- pipe.go
- port.go
- sendfile_linux.go
- sendfile_stub.go
- sock.go
- sock_bsd.go
- sock_linux.go
- tcpsock.go
- udpsock.go
- unixsock.go
Directories ¶
Path | Synopsis |
---|---|
Package dict implements the Dictionary Server Protocol as defined in RFC 2229.
|
Package dict implements the Dictionary Server Protocol as defined in RFC 2229. |
Package textproto implements generic support for text-based request/response protocols in the style of HTTP, NNTP, and SMTP.
|
Package textproto implements generic support for text-based request/response protocols in the style of HTTP, NNTP, and SMTP. |