socket

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTCPSockAddr added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.4.4

func SetIPv6Only(fd, ipv6only int) error

SetIPv6Only restricts a IPv6 socket to only process IPv6 requests or both IPv4 and IPv6 requests.

func SetKeepAlive

func SetKeepAlive(fd, secs int) error

SetKeepAlive sets whether the operating system should send keep-alive messages on the connection and sets period between keep-alive's.

func SetNoDelay

func SetNoDelay(fd, noDelay int) error

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

func SetRecvBuffer(fd, size int) error

SetRecvBuffer sets the size of the operating system's receive buffer associated with the connection.

func SetReuseAddr added in v1.6.0

func SetReuseAddr(fd, reuseAddr int) error

SetReuseAddr enables SO_REUSEADDR option on socket.

func SetReuseport

func SetReuseport(fd, reusePort int) error

SetReuseport enables SO_REUSEPORT option on socket.

func SetSendBuffer

func SetSendBuffer(fd, size int) error

SetSendBuffer sets the size of the operating system's transmit buffer associated with the connection.

func SockaddrToTCPOrUnixAddr

func SockaddrToTCPOrUnixAddr(sa unix.Sockaddr) net.Addr

SockaddrToTCPOrUnixAddr converts a Sockaddr to a net.TCPAddr or net.UnixAddr. Returns nil if conversion fails.

func SockaddrToUDPAddr

func SockaddrToUDPAddr(sa unix.Sockaddr) net.Addr

SockaddrToUDPAddr converts a Sockaddr to a net.UDPAddr Returns nil if conversion fails.

func TCPSocket

func TCPSocket(proto, addr string, passive bool, sockOpts ...Option) (int, net.Addr, error)

TCPSocket calls the internal tcpSocket.

func UDPSocket

func UDPSocket(proto, addr string, connect bool, sockOpts ...Option) (int, net.Addr, error)

UDPSocket calls the internal udpSocket.

func UnixSocket

func UnixSocket(proto, addr string, passive bool, sockOpts ...Option) (int, net.Addr, error)

UnixSocket calls the internal udsSocket.

Types

type Option

type Option struct {
	SetSockOpt func(int, int) error
	Opt        int
}

Option is used for setting an option on socket.

Jump to

Keyboard shortcuts

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