Documentation ¶
Overview ¶
Package socket provides functions that return fd and net.Addr based on given the protocol and address with a SO_REUSEPORT option set to the socket.
Index ¶
- func GetTCPSockAddr(proto, addr string) (sa unix.Sockaddr, family int, tcpAddr *net.TCPAddr, ipv6only bool, err error)
- func GetUDPSockAddr(proto, addr string) (sa unix.Sockaddr, family int, udpAddr *net.UDPAddr, ipv6only bool, err error)
- func GetUnixSockAddr(proto, addr string) (sa unix.Sockaddr, family int, unixAddr *net.UnixAddr, err error)
- func SetIPv6Only(fd, ipv6only int) error
- func SetKeepAlivePeriod(fd, secs int) error
- func SetLinger(fd, sec int) error
- func SetNoDelay(fd, noDelay int) error
- func SetRecvBuffer(fd, size int) error
- func SetReuseAddr(fd, reuseAddr int) error
- func SetReuseport(fd, reusePort int) error
- func SetSendBuffer(fd, size int) error
- func SockaddrToTCPOrUnixAddr(sa unix.Sockaddr) net.Addr
- func SockaddrToUDPAddr(sa unix.Sockaddr) net.Addr
- func TCPSocket(proto, addr string, passive bool, sockOpts ...Option) (int, net.Addr, error)
- func UDPSocket(proto, addr string, connect bool, sockOpts ...Option) (int, net.Addr, error)
- func UnixSocket(proto, addr string, passive bool, sockOpts ...Option) (int, net.Addr, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTCPSockAddr ¶
func GetTCPSockAddr(proto, addr string) (sa unix.Sockaddr, family int, tcpAddr *net.TCPAddr, ipv6only bool, err error)
GetTCPSockAddr the structured addresses based on the protocol and raw address.
func GetUDPSockAddr ¶
func GetUDPSockAddr(proto, addr string) (sa unix.Sockaddr, family int, udpAddr *net.UDPAddr, ipv6only bool, err error)
GetUDPSockAddr the structured addresses based on the protocol and raw address.
func GetUnixSockAddr ¶
func GetUnixSockAddr(proto, addr string) (sa unix.Sockaddr, family int, unixAddr *net.UnixAddr, err error)
GetUnixSockAddr the structured addresses based on the protocol and raw address.
func SetIPv6Only ¶
SetIPv6Only restricts a IPv6 socket to only process IPv6 requests or both IPv4 and IPv6 requests.
func SetKeepAlivePeriod ¶
SetKeepAlivePeriod sets whether the operating system should send keep-alive messages on the connection and sets period between TCP keep-alive probes.
func 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), the operating system finishes sending the data in the background.
If sec == 0, the operating system discards any unsent or unacknowledged data.
If sec > 0, the data is sent in the background as with sec < 0. On some operating systems after sec seconds have elapsed any remaining unsent data may be discarded.
func 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 SetRecvBuffer ¶
SetRecvBuffer sets the size of the operating system's receive buffer associated with the connection.
func SetReuseAddr ¶
SetReuseAddr enables SO_REUSEADDR option on socket.
func SetReuseport ¶
SetReuseport enables SO_REUSEPORT option on socket.
func SetSendBuffer ¶
SetSendBuffer sets the size of the operating system's transmit buffer associated with the connection.
func SockaddrToTCPOrUnixAddr ¶
SockaddrToTCPOrUnixAddr converts a Sockaddr to a net.TCPAddr or net.UnixAddr. Returns nil if conversion fails.
func SockaddrToUDPAddr ¶
SockaddrToUDPAddr converts a Sockaddr to a net.UDPAddr Returns nil if conversion fails.