SOCKET.H(3HEAD) | Headers | SOCKET.H(3HEAD) |
#include <sys/socket.h>
The <sys/socket.h> header defines the sockaddr structure that includes the following members:
sa_family_t sa_family /* address family */ char sa_data[] /* socket address (variable-length data) */
void *msg_name /* optional address */ socklen_t msg_namelen /* size of address */ struct iovec *msg_iov /* scatter/gather array */ int msg_iovlen /* members in msg_iov */ void *msg_control /* ancillary data, see below */ socklen_t msg_controllen /* ancillary data buffer len */ int msg_flags /* flags on received message */
The <sys/socket.h> header defines the cmsghdr structure for libxnet that includes the following members:
socklen_t cmsg_len /* data byte count, including hdr */ int cmsg_level /* originating protocol */ int cmsg_type /* protocol-specific type */
Ancillary data consists of a sequence of pairs, each consisting of a cmsghdr structure followed by a data array. The data array contains the ancillary data message, and the cmsghdr structure contains descriptive information that allows an application to correctly parse the data.
The values for cmsg_level will be legal values for the level argument to the getsockopt() and setsockopt() functions. The SCM_RIGHTS type is supported for level SOL_SOCKET.
Ancillary data is also possible at the socket level. The <sys/socket.h> header defines the following macros for use as the cmsg_type values when cmsg_level is SOL_SOCKET.
SCM_RIGHTS
SCM_UCRED
The IPv4 ancillary data formats are listed below by cmsg_level and cmsg_type, along with the associated payload for each.
IPPROTO_IP, IP_RECVDSTADDR — SOCK_DGRAM only
IPPROTO_IP, IP_RECVIF
IPPROTO_IP, IP_RECVOPTS — SOCK_DGRAM only
IPPROTO_IP, IP_RECVPKTINFO — SOCK_DGRAM only
IPPROTO_IP, IP_RECVSLLA — SOCK_DGRAM only
IPPROTO_IP, IP_RECVTTL — SOCK_DGRAM only
IPPROTO_IP, IP_RECVTOS
SOL_SOCKET, SO_UCRED
The IPv6 ancillary data formats are listed below by cmsg_level and cmsg_type, along with the associated payload for each.
IPPROTO_IPV6, IPV6_PKTINFO
IPPROTO_IPV6, IPV6_TCLASS
IPPROTO_IPV6, IPV6_PATHMTU
IPPROTO_IPV6, IPV6_HOPLIMIT
IPPROTO_IPV6, IPV6_HOPOPTS
IPPROTO_IPV6, IPV6_DSTOPTS
IPPROTO_IPV6, IPV6_RTHDR
IPPROTO_IPV6, IPV6_DSTOPTS
The <sys/socket.h> header defines the following macros to gain access to the data arrays in the ancillary data associated with a message header:
CMSG_DATA(cmsg)
CMSG_NXTHDR(mhdr, cmsg)
CMSG_FIRSTHDR(mhdr)
CMSG_SPACE(len)
CMSG_LEN(len)
The <sys/socket.h> header defines the linger structure that includes the following members:
int l_onoff /* indicates whether linger option is enabled */ int l_linger /* linger time, in seconds */
The <sys/socket.h> header defines the following macros:
SOCK_DGRAM
SOCK_STREAM
SOCK_SEQPACKET
The <sys/socket.h> header defines the following macros for use as the level argument of setsockopt() and getsockopt().
SOL_SOCKET
SOL_ROUTE
The <sys/socket.h> header defines the following macros for use as the option_name argument of getsockopt() or setsockopt() calls:
SO_DEBUG
SO_ACCEPTCONN
SO_BROADCAST
SO_REUSEADDR
SO_KEEPALIVE
SO_LINGER
SO_OOBINLINE
SO_SNDBUF
SO_RCVBUF
SO_ERROR
SO_TYPE
SO_RECVUCRED
SO_MAC_EXEMPT
SO_ALLZONES
The <sys/socket.h> header defines the following macros for use as the valid values for the msg_flags field in the msghdr structure, or the flags parameter in recvfrom(), recvmsg(), sendto(), or sendmsg() calls:
MSG_CTRUNC
MSG_EOR
MSG_OOB
MSG_PEEK
MSG_TRUNC
MSG_WAITALL
MSG_NOSIGNAL
The <sys/socket.h> header defines the following macros:
AF_UNIX
AF_INET
The <sys/socket.h> header defines the following macros:
SHUT_RD
SHUT_WR
SHUT_RDWR
void *msg_name /* optional address */ socklen_t msg_namelen /* size of address */ struct iovec *msg_iov /* scatter/gather array */ int msg_iovlen /* # elements in msg_iov */ caddr_t msg_accrights /* access rights sent/received */
The msg_name and msg_namelen parameters specify the destination address when the socket is unconnected The msg_name can be specified as a NULL pointer if no names are desired or required. The msg_iov and msg_iovlen parameters describe the scatter-gather locations, as described in read(2). The msg_accrights parameter specifies the buffer in which access rights sent along with the message are received. The msg_accrightslen specifies the length of the buffer.
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
September 18, 2020 |