socket

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept added in v1.1.0

func Accept(fd int) (int, syscall.Sockaddr, error)

Accept creates a non-blocking descriptor that cannot leak across exec.

func Dup

func Dup(fd int) (nfd int, err error)

Dup dups fd and marks it close-on-exec

func DupNetConn

func DupNetConn(conn net.Conn) (int, error)

func RecvUDP added in v1.1.0

func RecvUDP(fd int, packet []byte, receive *UDPReceive) (int, error)

RecvUDP receives one datagram without allocating a Sockaddr interface.

func SetIPv6Only

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 int, keepalive bool) error

SetKeepAlive sets whether the operating system should send keep-alive messages on the connection.

func SetKeepAlivePeriod

func SetKeepAlivePeriod(fd int, secs int) error

SetKeepAlivePeriod sets period between keep-alives.

func SetLinger

func SetLinger(fd, secs int) error

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

func SetNoDelay(fd int, nodelay bool) 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 SetNonblock

func SetNonblock(fd int, nonblocking bool) error

SetNonblock set this socket to use non-blocking mode or block mode.

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

func SetReuseAddr(fd, reuseAddr int) error

SetReuseAddr enables SO_REUSEADDR 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 SockaddrToAddr

func SockaddrToAddr(sa syscall.Sockaddr, udpAddr bool) net.Addr

SockaddrToAddr returns a go/net friendly address

func Writev

func Writev(fd int, iov [][]byte) (int, error)

Writev calls writev() on Linux.

Types

type UDPAddress added in v1.1.0

type UDPAddress struct {
	Addr   [16]byte
	Port   uint16
	Zone   uint32
	Family uint8
}

UDPAddress is a comparable source address suitable for use as a map key.

func (UDPAddress) NetAddr added in v1.1.0

func (addr UDPAddress) NetAddr() *net.UDPAddr

NetAddr allocates the user-visible address used only for a new peer.

func (UDPAddress) Sockaddr added in v1.1.0

func (addr UDPAddress) Sockaddr() syscall.Sockaddr

Sockaddr allocates the persistent send address used only for a new peer.

type UDPReceive added in v1.1.0

type UDPReceive struct {
	Addr UDPAddress
	// contains filtered or unexported fields
}

UDPReceive holds reusable source-address storage for RecvUDP.

Jump to

Keyboard shortcuts

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