]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man7/socket.7
socket.7: select()/poll()/epoll honor SO_RCVLOWAT since Linux 2.6.28
[thirdparty/man-pages.git] / man7 / socket.7
index c455c1cc2c72d6091910370dcc70a84e7053397e..30b699a071ecb7ac9793fea46c024cb1151ce6cc 100644 (file)
@@ -61,7 +61,7 @@
 .\"    commit ea02f9411d9faa3553ed09ce0ec9f00ceae9885e
 .\"    Author: Michal Sekletar <msekleta@redhat.com>
 .\"
-.TH SOCKET 7 2017-05-03 Linux "Linux Programmer's Manual"
+.TH SOCKET 7 2019-03-06 Linux "Linux Programmer's Manual"
 .SH NAME
 socket \- Linux socket interface
 .SH SYNOPSIS
@@ -274,9 +274,9 @@ The structure includes the following field, which can be used to identify
 the type of socket address actually stored in the structure:
 .PP
 .in +4n
-.nf
+.EX
     sa_family_t ss_family;
-.fi
+.EE
 .in
 .PP
 The
@@ -319,7 +319,7 @@ or an extended BPF
 program to the socket for use as a filter of incoming packets.
 A packet will be dropped if the filter program returns zero.
 If the filter program returns a
-non-zero value which is less than the packet's data length,
+nonzero value which is less than the packet's data length,
 the packet will be truncated to the length returned.
 If the value returned by the filter is greater than or equal to the
 packet's data length, the packet is allowed to proceed unmodified.
@@ -330,14 +330,14 @@ is a
 .I sock_fprog
 structure, defined in
 .IR <linux/filter.h> :
-.sp
+.IP
 .in +4n
-.nf
+.EX
 struct sock_fprog {
     unsigned short      len;
     struct sock_filter *filter;
 };
-.fi
+.EE
 .in
 .IP
 The argument for
@@ -345,7 +345,7 @@ The argument for
 is a file descriptor returned by the
 .BR bpf (2)
 system call and must refer to a program of type
-.BR BPF_PROG_TYPE_SOCKET_FILTER.
+.BR BPF_PROG_TYPE_SOCKET_FILTER .
 .IP
 These options may be set multiple times for a given socket,
 each time replacing the previous filter program.
@@ -397,7 +397,7 @@ takes the same argument type as
 and
 .BR SO_ATTACH_REUSEPORT_EBPF
 takes the same argument type as
-.BR SO_ATTACH_BPF.
+.BR SO_ATTACH_BPF .
 .IP
 UDP support for this feature is available since Linux 4.5;
 TCP support is available since Linux 4.6.
@@ -429,7 +429,7 @@ The
 .I optlen
 argument should contain the buffer size available
 to receive the device name and is recommended to be
-.BR IFNAMSZ
+.BR IFNAMSIZ
 bytes.
 The real device name length is reported back in the
 .I optlen
@@ -497,11 +497,10 @@ Sets or gets the CPU affinity of a socket.
 Expects an integer flag.
 .IP
 .in +4n
-.nf
+.EX
 int cpu = 1;
-socklen_t len = sizeof(cpu);
-setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, &len);
-.fi
+setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, sizeof(cpu));
+.EE
 .in
 .IP
 Because all of the packets for a single stream
@@ -541,14 +540,14 @@ option.
 The argument is a
 .I linger
 structure.
-.sp
+.IP
 .in +4n
-.nf
+.EX
 struct linger {
     int l_onoff;    /* linger active */
     int l_linger;   /* how many seconds to linger for */
 };
-.fi
+.EE
 .in
 .IP
 When enabled, a
@@ -568,11 +567,11 @@ it always lingers in the background.
 When set, this option will prevent
 changing the filters associated with the socket.
 These filters include any set using the socket options
-.BR SO_ATTACH_FILTER,
-.BR SO_ATTACH_BPF,
-.BR SO_ATTACH_REUSEPORT_CBPF
+.BR SO_ATTACH_FILTER ,
+.BR SO_ATTACH_BPF ,
+.BR SO_ATTACH_REUSEPORT_CBPF ,
 and
-.BR SO_ATTACH_REUSEPORT_EPBF .
+.BR SO_ATTACH_REUSEPORT_EBPF .
 .IP
 The typical use case is for a privileged process to set up a raw socket
 (an operation that requires the
@@ -624,8 +623,13 @@ Enable or disable the receiving of the
 control message.
 For more information see
 .BR unix (7).
-.\" FIXME Document SO_PASSSEC, added in 2.6.18; there is some info
-.\" in the 2.6.18 ChangeLog
+.TP
+.B SO_PASSSEC
+Enable or disable the receiving of the
+.B SCM_SECURITY
+control message.
+For more information see
+.BR unix (7).
 .TP
 .BR SO_PEEK_OFF " (since Linux 3.4)"
 .\" commit ef64a54f6e558155b4f149bb10666b9e914b6c54
@@ -680,7 +684,7 @@ The following sequence of
 calls would have the effect noted in the comments:
 .IP
 .in +4n
-.nf
+.EX
 int ov = 4;                  // Set peek offset to 4
 setsockopt(fd, SOL_SOCKET, SO_PEEK_OFF, &ov, sizeof(ov));
 
@@ -688,31 +692,13 @@ recv(fd, buf, 2, MSG_PEEK);  // Peeks "cc"; offset set to 6
 recv(fd, buf, 2, MSG_PEEK);  // Peeks "dd"; offset set to 8
 recv(fd, buf, 2, 0);         // Reads "aa"; offset set to 6
 recv(fd, buf, 2, MSG_PEEK);  // Peeks "ee"; offset set to 8
-.fi
+.EE
 .in
 .TP
 .B SO_PEERCRED
-Return the credentials of the foreign process connected to this socket.
-This is possible only for connected
-.B AF_UNIX
-stream sockets and
-.B AF_UNIX
-stream and datagram socket pairs created using
-.BR socketpair (2);
-see
+Return the credentials of the peer process connected to this socket.
+For further details, see
 .BR unix (7).
-The returned credentials are those that were in effect at the time
-of the call to
-.BR connect (2)
-or
-.BR socketpair (2).
-The argument is a
-.I ucred
-structure; define the
-.B _GNU_SOURCE
-feature test macro to obtain the definition of that structure from
-.IR <sys/socket.h> .
-This socket option is read-only.
 .TP
 .B SO_PRIORITY
 Set the protocol-defined priority for all packets to be sent on
@@ -778,15 +764,19 @@ fails with the error
 .B SO_RCVLOWAT
 is changeable
 only since Linux 2.4.
-The
-.BR select (2)
+.IP
+Before Linux 2.6.28
+.\" commit c7004482e8dcb7c3c72666395cfa98a216a4fb70
+.BR select (2),
+.BR poll (2),
 and
-.BR poll (2)
-system calls currently do not respect the
+.BR epoll (7)
+did not respect the
 .B SO_RCVLOWAT
 setting on Linux,
-and mark a socket readable when even a single byte of data is available.
-A subsequent read from the socket will block until
+and indicated a socket as readable when even a single byte of data
+was available.
+A subsequent read from the socket would then block until
 .B SO_RCVLOWAT
 bytes are available.
 .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=111049368106984&w=2
@@ -881,8 +871,7 @@ compete to receive datagrams on the same socket.
 .\" commit 3b885787ea4112eaa80945999ea0901bf742707f
 Indicates that an unsigned 32-bit value ancillary message (cmsg)
 should be attached to received skbs indicating
-the number of packets dropped by the socket between
-the last received packet and this received packet.
+the number of packets dropped by the socket since its creation.
 .TP
 .B SO_SNDBUF
 Sets or gets the maximum socket send buffer in bytes.
@@ -1039,9 +1028,9 @@ These operations can be accessed using
 .BR ioctl (2):
 .PP
 .in +4n
-.nf
+.EX
 .IB error " = ioctl(" ip_socket ", " ioctl_type ", " &value_result ");"
-.fi
+.EE
 .in
 .TP
 .B SIOCGSTAMP
@@ -1163,6 +1152,7 @@ program is designed to always set this option.
 .BR setsockopt (2),
 .BR socket (2),
 .BR pcap (3),
+.BR address_families (7),
 .BR capabilities (7),
 .BR ddp (7),
 .BR ip (7),