Module nix::sys::socket [] [src]

Socket interface functions

Further reading

Modules

sockopt

Structs

CmsgIterator
CmsgSpace

A structure used to make room in a cmsghdr passed to recvmsg. The size and alignment match that of a cmsghdr followed by a T, but the fields are not accessible, as the actual types will change on a call to recvmsg.

Ipv4Addr
Ipv6Addr
MsgFlags
NetlinkAddr
RecvMsg
SockFlag
UnixAddr

A wrapper around sockaddr_un. We track the length of sun_path (excluding a terminating null), because it may not be null-terminated. For example, unconnected and Linux abstract sockets are never null-terminated, and POSIX does not require that sun_len include the terminating null even for normal sockets. Note that the actual sockaddr length is greater by offset_of!(libc::sockaddr_un, sun_path)

in6_addr
in_addr
ip_mreq
ipv6_mreq
linger
sockaddr
sockaddr_in
sockaddr_in6
sockaddr_storage
sockaddr_un
ucred

Enums

AddressFamily
ControlMessage

A type-safe wrapper around a single control message. More types may be added to this enum; do not exhaustively pattern-match it. Further reading

InetAddr
IpAddr
Shutdown
SockAddr

Represents a socket address

SockLevel

The protocol level at which to get / set socket options. Used as an argument to getsockopt and setsockopt.

SockType

Constants

AF_INET
AF_INET6
AF_LOCAL
AF_NETLINK
AF_PACKET
AF_UNIX
INADDR_ANY
INADDR_BROADCAST
INADDR_NONE
IPPROTO_IP
IPPROTO_IPV6
IPPROTO_TCP
IPPROTO_UDP
IPV6_ADD_MEMBERSHIP
IPV6_DROP_MEMBERSHIP
IP_ADD_MEMBERSHIP
IP_DROP_MEMBERSHIP
IP_MULTICAST_IF
IP_MULTICAST_LOOP
IP_MULTICAST_TTL
MSG_CMSG_CLOEXEC
MSG_CTRUNC
MSG_DONTWAIT
MSG_EOR
MSG_ERRQUEUE
MSG_OOB
MSG_PEEK
MSG_TRUNC
SCM_RIGHTS
SHUT_RD
SHUT_RDWR
SHUT_WR
SOCK_CLOEXEC
SOCK_DGRAM
SOCK_NONBLOCK
SOCK_RAW
SOCK_RDM
SOCK_SEQPACKET
SOCK_STREAM
SOL_IP
SOL_IPV6
SOL_NETLINK
SOL_SOCKET
SOL_TCP
SOL_UDP
SO_ACCEPTCONN
SO_BINDTODEVICE
SO_BROADCAST
SO_BSDCOMPAT
SO_BUSY_POLL
SO_DEBUG
SO_DOMAIN
SO_DONTROUTE
SO_ERROR
SO_KEEPALIVE
SO_LINGER
SO_MARK
SO_OOBINLINE
SO_ORIGINAL_DST
SO_PASSCRED
SO_PEEK_OFF
SO_PEERCRED
SO_PRIORITY
SO_PROTOCOL
SO_RCVBUF
SO_RCVBUFFORCE
SO_RCVLOWAT
SO_RCVTIMEO
SO_REUSEADDR
SO_REUSEPORT
SO_RXQ_OVFL
SO_SNDBUF
SO_SNDBUFFORCE
SO_SNDLOWAT
SO_SNDTIMEO
SO_TIMESTAMP
SO_TYPE
TCP_CORK
TCP_KEEPIDLE
TCP_MAXSEG
TCP_NODELAY

Traits

GetSockOpt

Represents a socket option that can be accessed or set. Used as an argument to getsockopt

SetSockOpt

Represents a socket option that can be accessed or set. Used as an argument to setsockopt

Functions

accept

Accept a connection on a socket

accept4

Accept a connection on a socket

bind

Bind a name to a socket

connect

Initiate a connection on a socket

getpeername

Get the address of the peer connected to the socket fd.

getsockname

Get the current address to which the socket fd is bound.

getsockopt

Get the current value for the requested socket option

listen

Listen for connections on a socket

recv

Receive data from a connection-oriented socket. Returns the number of bytes read

recvfrom

Receive data from a connectionless or connection-oriented socket. Returns the number of bytes read and the socket address of the sender.

recvmsg

Receive message in scatter-gather vectors from a socket, and optionally receive ancillary data into the provided buffer. If no ancillary data is desired, use () as the type parameter.

send

Send data to a connection-oriented socket. Returns the number of bytes read

sendmsg

Send data in scatter-gather vectors to a socket, possibly accompanied by ancillary data. Optionally direct the message at the given address, as with sendto.

sendto
setsockopt

Sets the value for the requested socket option

shutdown

Shut down part of a full-duplex connection.

sockaddr_storage_to_addr

Return the appropriate SockAddr type from a sockaddr_storage of a certain size. In C this would usually be done by casting. The len argument should be the number of bytes in the sockaddr_storage that are actually allocated and valid. It must be at least as large as all the useful parts of the structure. Note that in the case of a sockaddr_un, len need not include the terminating null.

socket

Create an endpoint for communication

socketpair

Create a pair of connected sockets

Type Definitions

InAddrT
IpMulticastTtl
sa_family_t