{"id":5874,"date":"2022-12-20T18:57:40","date_gmt":"2022-12-20T21:57:40","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/sys_socket-h-man0p\/"},"modified":"2022-12-20T18:57:40","modified_gmt":"2022-12-20T21:57:40","slug":"sys_socket-h-man0p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/sys_socket-h-man0p\/","title":{"rendered":"sys_socket.h (man0p)"},"content":{"rendered":"<h1 align=\"center\">sys_socket.h<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">sys\/socket.h \u2014 main sockets header<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <sys\/socket.h><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>socklen_t<\/b> type, which is an integer type of width of at least 32 bits; see APPLICATION USAGE.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>sa_family_t<\/b> unsigned integer type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>sockaddr<\/b> structure, which shall include at least the following members:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">sa_family_t sa_family Address family. <br \/> char sa_data[] Socket address (variable-length data).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>sockaddr<\/b> structure is used to define a socket address which is used in the <i>bind<\/i>(), <i>connect<\/i>(), <i>getpeername<\/i>(), <i>getsockname<\/i>(), <i>recvfrom<\/i>(), and <i>sendto<\/i>() functions.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>sockaddr_storage<\/b> structure, which shall be:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>Large enough to accommodate all supported protocol-specific address structures<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>Aligned at an appropriate boundary so that pointers to it can be cast as pointers to protocol-specific address structures and used to access the fields of those structures without alignment problems<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>sockaddr_storage<\/b> structure shall include at least the following members:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">sa_family_t ss_family<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When a pointer to a <b>sockaddr_storage<\/b> structure is cast as a pointer to a <b>sockaddr<\/b> structure, the <i>ss_family<\/i> field of the <b>sockaddr_storage<\/b> structure shall map onto the <i>sa_family<\/i> field of the <b>sockaddr<\/b> structure. When a pointer to a <b>sockaddr_storage<\/b> structure is cast as a pointer to a protocol-specific address structure, the <i>ss_family<\/i> field shall map onto a field of that structure that is of type <b>sa_family_t<\/b> and that identifies the protocol\u2019s address family.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>msghdr<\/b> structure, which shall include at least the following members:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">void *msg_name Optional address. <br \/> socklen_t msg_namelen Size of address. <br \/> struct iovec *msg_iov Scatter\/gather array. <br \/> int msg_iovlen Members in <i>msg_iov<\/i>. <br \/> void *msg_control Ancillary data; see below. <br \/> socklen_t msg_controllen Ancillary data buffer <i>len<\/i>. <br \/> int msg_flags Flags on received message.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>msghdr<\/b> structure is used to minimize the number of directly supplied parameters to the <i>recvmsg<\/i>() and <i>sendmsg<\/i>() functions. This structure is used as a <i>value<\/i>&#8211;<i>result<\/i> parameter in the <i>recvmsg<\/i>() function and <i>value<\/i> only for the <i>sendmsg<\/i>() function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>iovec<\/b> structure as described in <i><sys\/uio.h><\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>cmsghdr<\/b> structure, which shall include at least the following members:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">socklen_t cmsg_len Data byte count, including the <b>cmsghdr<\/b>. <br \/> int cmsg_level Originating protocol. <br \/> int cmsg_type Protocol-specific type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>cmsghdr<\/b> structure is used for storage of ancillary data object information.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Ancillary data consists of a sequence of pairs, each consisting of a <b>cmsghdr<\/b> structure followed by a data array. The data array contains the ancillary data message, and the <b>cmsghdr<\/b> structure contains descriptive information that allows an application to correctly parse the data.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The values for <i>cmsg_level<\/i> shall be legal values for the <i>level<\/i> argument to the <i>getsockopt<\/i>() and <i>setsockopt<\/i>() functions. The system documentation shall specify the <i>cmsg_type<\/i> definitions for the supported protocols.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Ancillary data is also possible at the socket level. The <i><sys\/socket.h><\/i> header shall define the following symbolic constant for use as the <i>cmsg_type<\/i> value when <i>cmsg_level<\/i> is SOL_SOCKET:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p style=\"margin-top: 1em\">SCM_RIGHTS<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Indicates that the data array contains the access rights to be sent or received.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following macros to gain access to the data arrays in the ancillary data associated with a message header: <br \/> CMSG_DATA(<i>cmsg<\/i>)<\/p>\n<p style=\"margin-left:20%;\">If the argument is a pointer to a <b>cmsghdr<\/b> structure, this macro shall return an unsigned character pointer to the data array associated with the <b>cmsghdr<\/b> structure.<\/p>\n<p style=\"margin-left:11%;\">CMSG_NXTHDR(<i>mhdr,cmsg<\/i>)<\/p>\n<p style=\"margin-left:20%;\">If the first argument is a pointer to a <b>msghdr<\/b> structure and the second argument is a pointer to a <b>cmsghdr<\/b> structure in the ancillary data pointed to by the <i>msg_control<\/i> field of that <b>msghdr<\/b> structure, this macro shall return a pointer to the next <b>cmsghdr<\/b> structure, or a null pointer if this structure is the last <b>cmsghdr<\/b> in the ancillary data.<\/p>\n<p style=\"margin-left:11%;\">CMSG_FIRSTHDR(<i>mhdr<\/i>)<\/p>\n<p style=\"margin-left:20%;\">If the argument is a pointer to a <b>msghdr<\/b> structure, this macro shall return a pointer to the first <b>cmsghdr<\/b> structure in the ancillary data associated with this <b>msghdr<\/b> structure, or a null pointer if there is no ancillary data associated with the <b>msghdr<\/b> structure.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>linger<\/b> structure, which shall include at least the following members:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">int l_onoff Indicates whether linger option is enabled. <br \/> int l_linger Linger time, in seconds.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constants with distinct values:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p>SOCK_DGRAM<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"36%\">\n<p>Datagram socket.<\/p>\n<\/td>\n<td width=\"32%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p>SOCK_RAW<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"36%\">\n<p>Raw Protocol Interface.<\/p>\n<\/td>\n<td width=\"32%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\">SOCK_SEQPACKET<\/p>\n<p style=\"margin-left:32%;\">Sequenced-packet socket.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"17%\">\n<p>SOCK_STREAM<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"30%\">\n<p>Byte-stream socket.<\/p>\n<\/td>\n<td width=\"38%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constant for use as the <i>level<\/i> argument of <i>setsockopt<\/i>() and <i>getsockopt<\/i>().<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p style=\"margin-top: 1em\">SOL_SOCKET<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Options to be accessed at socket level, not protocol level.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constants with distinct values for use as the <i>option_name<\/i> argument in <i>getsockopt<\/i>() or <i>setsockopt<\/i>() calls (see the System Interfaces volume of POSIX.1-2017, <i>Section 2.10.16<\/i>, <i>Use of Options<\/i>):<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p style=\"margin-top: 1em\">SO_ACCEPTCONN<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Socket is accepting connections.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_BROADCAST<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Transmission of broadcast messages is supported.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_DEBUG<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Debugging information is being recorded.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_DONTROUTE<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Bypass normal routing.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_ERROR<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Socket error status.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_KEEPALIVE<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Connections are kept alive with periodic messages.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_LINGER<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Socket lingers on close.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_OOBINLINE<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Out-of-band data is transmitted in line.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_RCVBUF<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Receive buffer size.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_RCVLOWAT<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Receive \u2018\u2018low water mark\u2019\u2019.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_RCVTIMEO<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Receive timeout.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_REUSEADDR<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Reuse of local addresses is supported.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_SNDBUF<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Send buffer size.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_SNDLOWAT<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Send \u2018\u2018low water mark\u2019\u2019.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_SNDTIMEO<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Send timeout.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>SO_TYPE<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Socket type.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constant for use as the maximum <i>backlog<\/i> queue length which may be specified by the <i>backlog<\/i> field of the <i>listen<\/i>() function:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p style=\"margin-top: 1em\">SOMAXCONN<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"51%\">\n<p style=\"margin-top: 1em\">The maximum <i>backlog<\/i> queue length.<\/p>\n<\/td>\n<td width=\"17%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constants with distinct values for use as the valid values for the <i>msg_flags<\/i> field in the <b>msghdr<\/b> structure, or the <i>flags<\/i> parameter in <i>recv<\/i>(), <i>recvfrom<\/i>(), <i>recvmsg<\/i>(), <i>send<\/i>(), <i>sendmsg<\/i>(), or <i>sendto<\/i>() calls:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p style=\"margin-top: 1em\">MSG_CTRUNC<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Control data truncated.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_DONTROUTE<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Send without using routing tables.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_EOR<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Terminates a record (if supported by the protocol).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_OOB<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Out-of-band data.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_NOSIGNAL<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>No SIGPIPE generated when an attempt to send is made on a stream-oriented socket that is no longer connected.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_PEEK<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Leave received data in queue.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_TRUNC<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Normal data truncated.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"20%\">\n<p>MSG_WAITALL<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Attempt to fill the read buffer.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constants with distinct values:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p style=\"margin-top: 1em\">AF_INET<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Internet domain sockets for use with IPv4 addresses.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p>AF_INET6<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p>Internet domain sockets for use with IPv6 addresses.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p>AF_UNIX<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p>UNIX domain sockets.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p>AF_UNSPEC<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p>Unspecified.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The value of AF_UNSPEC shall be 0.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the following symbolic constants with distinct values:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p style=\"margin-top: 1em\">SHUT_RD<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Disables further receive operations.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p>SHUT_RDWR<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p>Disables further send and receive operations.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p>SHUT_WR<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"68%\">\n<p>Disables further send operations.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/socket.h><\/i> header shall define the <b>size_t<\/b> and <b>ssize_t<\/b> types as described in <i><sys\/types.h><\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">int accept(int, struct sockaddr *restrict, socklen_t *restrict); <br \/> int bind(int, const struct sockaddr *, socklen_t); <br \/> int connect(int, const struct sockaddr *, socklen_t); <br \/> int getpeername(int, struct sockaddr *restrict, socklen_t *restrict); <br \/> int getsockname(int, struct sockaddr *restrict, socklen_t *restrict); <br \/> int getsockopt(int, int, int, void *restrict, socklen_t *restrict); <br \/> int listen(int, int); <br \/> ssize_t recv(int, void *, size_t, int); <br \/> ssize_t recvfrom(int, void *restrict, size_t, int, <br \/> struct sockaddr *restrict, socklen_t *restrict); <br \/> ssize_t recvmsg(int, struct msghdr *, int); <br \/> ssize_t send(int, const void *, size_t, int); <br \/> ssize_t sendmsg(int, const struct msghdr *, int); <br \/> ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, <br \/> socklen_t); <br \/> int setsockopt(int, int, int, const void *, socklen_t); <br \/> int shutdown(int, int); <br \/> int sockatmark(int); <br \/> int socket(int, int, int); <br \/> int socketpair(int, int, int, int [2]);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Inclusion of <i><sys\/socket.h><\/i> may also make visible all symbols from <i><sys\/uio.h><\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">To forestall portability problems, it is recommended that applications not use values larger than 2 <small><small>31<\/small><\/small> \u22121 for the <b>socklen_t<\/b> type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>sockaddr_storage<\/b> structure solves the problem of declaring storage for automatic variables which is both large enough and aligned enough for storing the socket address data structure of any family. For example, code with a file descriptor and without the context of the address family can pass a pointer to a variable of this type, where a pointer to a socket address structure is expected in calls such as <i>getpeername<\/i>(), and determine the address family by accessing the received content after the call.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The example below illustrates a data structure which aligns on a 64-bit boundary. An implementation-defined field <i>_ss_align<\/i> following <i>_ss_pad1<\/i> is used to force a 64-bit alignment which covers proper alignment good enough for needs of at least <b>sockaddr_in6<\/b> (IPv6) and <b>sockaddr_in<\/b> (IPv4) address data structures. The size of padding field <i>_ss_pad1<\/i> depends on the chosen alignment boundary. The size of padding field <i>_ss_pad2<\/i> depends on the value of overall size chosen for the total size of the structure. This size and alignment are represented in the above example by implementation-defined (not required) constants _SS_MAXSIZE (chosen value 128) and _SS_ALIGNMENT (with chosen value 8). Constants _SS_PAD1SIZE (derived value 6) and _SS_PAD2SIZE (derived value 112) are also for illustration and not required. The implementation-defined definitions and structure field names above start with an <underscore> to denote implementation private name space. Portable code is not expected to access or reference those fields or constants.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr Desired design of maximum size and alignment. <br \/> bodies\/ usr\/ <br \/> #define _SS_MAXSIZE 128 <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Implementation-defined maximum size. bodies\/ usr\/ <br \/> #define _SS_ALIGNSIZE (sizeof(int64_t)) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Implementation-defined desired alignment. *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr Definitions used for sockaddr_storage structure paddings design. <br \/> bodies\/ usr\/ <br \/> #define _SS_PAD1SIZE (_SS_ALIGNSIZE &#8211; sizeof(sa_family_t)) <br \/> #define _SS_PAD2SIZE (_SS_MAXSIZE &#8211; (sizeof(sa_family_t)+  <br \/> _SS_PAD1SIZE + _SS_ALIGNSIZE)) <br \/> struct sockaddr_storage { <br \/> sa_family_t ss_family; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Address family. bodies\/ usr\/ <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr Following fields are implementation-defined. <br \/> bodies\/ usr\/ <br \/> char _ss_pad1[_SS_PAD1SIZE]; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var 6-byte pad; this is to make implementation-defined <br \/> pad up to alignment field that follows explicit in <br \/> the data structure. bodies\/ usr\/ <br \/> int64_t _ss_align; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Field to force desired structure <br \/> storage alignment. bodies\/ usr\/ <br \/> char _ss_pad2[_SS_PAD2SIZE]; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var 112-byte pad to achieve desired size, <br \/> _SS_MAXSIZE value minus size of ss_family <br \/> __ss_pad1, __ss_align fields is 112. bodies\/ usr\/ <br \/> };<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b><sys_types.h><\/b>, <b><sys_uio.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The System Interfaces volume of POSIX.1-2017, <i>accept<\/i>(), <i>bind<\/i>(), <i>connect<\/i>(), <i>getpeername<\/i>(), <i>getsockname<\/i>(), <i>getsockopt<\/i>(), <i>listen<\/i>(), <i>recv<\/i>(), <i>recvfrom<\/i>(), <i>recvmsg<\/i>(), <i>send<\/i>(), <i>sendmsg<\/i>(), <i>sendto<\/i>(), <i>setsockopt<\/i>(), <i>shutdown<\/i>(), <i>sockatmark<\/i>(), <i>socket<\/i>(), <i>socketpair<\/i>()<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  sys\/socket.h \u2014 main sockets header <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3781,1],"tags":[2588,2598],"class_list":["post-5874","post","type-post","status-publish","format-standard","hentry","category-0p-posix-cabeceras-de-bibliotecas-de-c","category-sin-categoria","tag-man0p","tag-sys_socket"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=5874"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5874\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}