SOCKET.H(3HEAD) | Headers | SOCKET.H(3HEAD) |
socket.h, socket, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, CMSG_SPACE - Internet Protocol family
#include <sys/socket.h>
The <sys/socket.h> header defines the unsigned integral type sa_family_t through typedef.
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) */
The <sys/socket.h> header defines the msghdr structure for libxnet interfaces that includes the following members:
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 which indicate types of sockets:
SOCK_DGRAM
SOCK_STREAM
SOCK_RAW
SOCK_RDM
SOCK_SEQPACKET
In some cases, the above types are bitwise-inclusive-ORed with zero or more of the following macros which modify the socket's default behavior:
SOCK_CLOEXEC
SOCK_CLOFORK
SOCK_NDELAY
SOCK_NONBLOCK
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_DOMAIN
SO_TYPE
SO_PROTOCOL, SO_PROTOTYPE
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
MSG_CMSG_CLOEXEC
MSG_CMSG_CLOFORK
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
The <sys/socket.h> header defines the msghdr structure for libsocket interfaces that includes the following members:
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.
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
getpeerucred(3C), ucred_get(3C), libsocket(3LIB), accept(3SOCKET), bind(3SOCKET), connect(3SOCKET), getpeername(3SOCKET), getsockname(3SOCKET), getsockopt(3SOCKET), listen(3SOCKET), recv(3SOCKET), recvfrom(3SOCKET), recvmsg(3SOCKET), send(3SOCKET), sendmsg(3SOCKET), sendto(3SOCKET), setsockopt(3SOCKET), shutdown(3SOCKET), sockaddr(3SOCKET), socket(3SOCKET), socketpair(3SOCKET), accept(3XNET), bind(3XNET), connect(3XNET), getpeername(3XNET), getsockname(3XNET), getsockopt(3XNET), listen(3XNET), recv(3XNET), recvfrom(3XNET), recvmsg(3XNET), send(3XNET), sendmsg(3XNET), sendto(3XNET), setsockopt(3XNET), shutdown(3XNET), socket(3XNET), socketpair(3XNET), attributes(7), standards(7)
July 2, 2024 | OmniOS |