]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/socket.7
Change "e.g. " to "e.g., ", or in some cases, "for example, ".
[thirdparty/man-pages.git] / man7 / socket.7
CommitLineData
fea681da
MK
1'\" t
2.\" Don't change the first line, it tells man that we need tbl.
3.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
c13182ef 4.\" and copyright (c) 1999 Matthew Wilcox.
fea681da
MK
5.\" Permission is granted to distribute possibly modified copies
6.\" of this page provided the header is included verbatim,
7.\" and in case of nontrivial modification author and date
8.\" of the modification is added to the header.
9.\"
305a0578 10.\" 2002-10-30, Michael Kerrisk, <mtk-manpages@gmx.net>
fea681da
MK
11.\" Added description of SO_ACCEPTCONN
12.\" 2004-05-20, aeb, added SO_RCVTIMEO/SO_SNDTIMEO text.
305a0578 13.\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
14.\" Added notes on capability requirements
15.\" A few small grammar fixes
c13182ef 16.\"
218e46f8 17.\" FIXME probably all PF_* should be AF_* in this page, since
fea681da
MK
18.\" POSIX only specifies the latter values.
19.\"
d9343c5c 20.TH SOCKET 7 2004-05-27 "Linux" "Linux Programmer's Manual"
fea681da 21.SH NAME
4d9b6984 22socket \- Linux socket interface
fea681da
MK
23.SH SYNOPSIS
24.B #include <sys/socket.h>
25.br
26.IB mysocket " = socket(int " socket_family ", int " socket_type ", int " protocol );
fea681da 27.SH DESCRIPTION
c13182ef
MK
28This manual page describes the Linux networking socket layer user
29interface.
30The BSD compatible sockets
fea681da
MK
31are the uniform interface
32between the user process and the network protocol stacks in the kernel.
c13182ef 33The protocol modules are grouped into
fea681da
MK
34.I protocol families
35like
36.BR PF_INET ", " PF_IPX ", " PF_PACKET
37and
38.I socket types
39like
40.B SOCK_STREAM
41or
42.BR SOCK_DGRAM .
c13182ef 43See
fea681da
MK
44.BR socket (2)
45for more information on families and types.
2b2581ee 46.SS Socket Layer Functions
c13182ef
MK
47These functions are used by the user process to send or receive packets
48and to do other socket operations.
56185b42 49For more information see their respective manual pages.
fea681da
MK
50
51.BR socket (2)
52creates a socket,
53.BR connect (2)
54connects a socket to a remote socket address,
c13182ef 55the
fea681da
MK
56.BR bind (2)
57function binds a socket to a local socket address,
58.BR listen (2)
59tells the socket that new connections shall be accepted, and
60.BR accept (2)
61is used to get a new socket with a new incoming connection.
62.BR socketpair (2)
63returns two connected anonymous sockets (only implemented for a few
64local families like
65.BR PF_UNIX )
66.PP
67.BR send (2),
68.BR sendto (2),
69and
70.BR sendmsg (2)
71send data over a socket, and
72.BR recv (2),
73.BR recvfrom (2),
74.BR recvmsg (2)
75receive data from a socket.
76.BR poll (2)
77and
78.BR select (2)
79wait for arriving data or a readiness to send data.
c13182ef 80In addition, the standard I/O operations like
fea681da
MK
81.BR write (2),
82.BR writev (2),
83.BR sendfile (2),
84.BR read (2),
c13182ef
MK
85and
86.BR readv (2)
fea681da
MK
87can be used to read and write data.
88.PP
89.BR getsockname (2)
90returns the local socket address and
91.BR getpeername (2)
92returns the remote socket address.
93.BR getsockopt (2)
94and
95.BR setsockopt (2)
c13182ef 96are used to set or get socket layer or protocol options.
fea681da
MK
97.BR ioctl (2)
98can be used to set or read some other options.
99.PP
100.BR close (2)
101is used to close a socket.
102.BR shutdown (2)
c13182ef 103closes parts of a full duplex socket connection.
fea681da 104.PP
c13182ef
MK
105Seeking, or calling
106.BR pread (2)
107or
fea681da
MK
108.BR pwrite (2)
109with a non-zero position is not supported on sockets.
110.PP
c13182ef 111It is possible to do non-blocking I/O on sockets by setting the
fea681da
MK
112.B O_NONBLOCK
113flag on a socket file descriptor using
114.BR fcntl (2).
115Then all operations that would block will (usually)
116return with
c13182ef 117.B EAGAIN
fea681da 118(operation should be retried later);
c13182ef
MK
119.BR connect (2)
120will return
fea681da 121.B EINPROGRESS
c13182ef 122error.
fea681da
MK
123The user can then wait for various events via
124.BR poll (2)
125or
c13182ef 126.BR select (2).
fea681da
MK
127.TS
128tab(:) allbox;
129c s s
130l l l.
131I/O events
132Event:Poll flag:Occurrence
133Read:POLLIN:T{
c13182ef 134New data arrived.
fea681da
MK
135T}
136Read:POLLIN:T{
137A connection setup has been completed
138(for connection-oriented sockets)
139T}
140Read:POLLHUP:T{
c13182ef 141A disconnection request has been initiated by the other end.
fea681da
MK
142T}
143Read:POLLHUP:T{
c13182ef 144A connection is broken (only for connection-oriented protocols).
fea681da 145When the socket is written
c13182ef 146.B SIGPIPE
fea681da
MK
147is also sent.
148T}
149Write:POLLOUT:T{
150Socket has enough send buffer space for writing new data.
151T}
152Read/Write:T{
153POLLIN|
154.br
155POLLOUT
156T}:T{
157An outgoing
158.BR connect (2)
159finished.
160T}
161Read/Write:POLLERR:An asynchronous error occurred.
162Read/Write:POLLHUP:The other end has shut down one direction.
163Exception:POLLPRI:T{
c13182ef 164Urgent data arrived.
fea681da
MK
165.B SIGURG
166is sent then.
167T}
c533af9d 168.\" FIXME The following is not true currently:
fea681da 169.\" It is no I/O event when the connection
c13182ef 170.\" is broken from the local end using
fea681da 171.\" .BR shutdown (2)
c13182ef 172.\" or
c533af9d 173.\" .BR close (2).
fea681da
MK
174.TE
175
176.PP
c13182ef 177An alternative to
63f6a20a 178.BR poll (2)
1e321034 179and
63f6a20a 180.BR select (2)
fea681da
MK
181is to let the kernel inform the application about events
182via a
183.B SIGIO
c13182ef
MK
184signal.
185For that the
fea681da 186.B FASYNC
1e321034 187flag must be set on a socket file descriptor via
fea681da 188.BR fcntl (2)
c13182ef 189and a valid signal handler for
fea681da 190.B SIGIO
c13182ef
MK
191must be installed via
192.BR sigaction (2).
fea681da
MK
193See the
194.I SIGNALS
195discussion below.
2b2581ee 196.SS Socket Options
fea681da
MK
197These socket options can be set by using
198.BR setsockopt (2)
c13182ef 199and read with
fea681da 200.BR getsockopt (2)
c13182ef
MK
201with the socket level set to
202.B SOL_SOCKET
fea681da 203for all sockets:
c13182ef 204.\" SO_ACCEPTCONN is in POSIX.1-2001, and its origin is explained in
ec4db3e7
MK
205.\" W R Stevens, UNPv1
206.TP
207.B SO_ACCEPTCONN
208Returns a value indicating whether or not this socket has been marked
209to accept connections with
63f6a20a 210.BR listen (2).
ec4db3e7
MK
211The value 0 indicates that this is not a listening socket,
212the value 1 indicates that this is a listening socket.
213Can only be read
c13182ef 214with
63f6a20a 215.BR getsockopt (2).
ec4db3e7 216.TP
ec4db3e7
MK
217.B SO_BINDTODEVICE
218Bind this socket to a particular device like \(lqeth0\(rq,
c13182ef
MK
219as specified in the passed interface name.
220If the
ec4db3e7 221name is an empty string or the option length is zero, the socket device
c13182ef
MK
222binding is removed.
223The passed option is a variable-length null terminated
224interface name string with the maximum size of
ec4db3e7
MK
225.BR IFNAMSIZ .
226If a socket is bound to an interface,
c13182ef
MK
227only packets received from that particular interface are processed by the
228socket.
229Note that this only works for some socket types, particularly
ec4db3e7 230.B AF_INET
c13182ef
MK
231sockets.
232It is not supported for packet sockets (use normal
ec4db3e7
MK
233.BR bind (8)
234there).
235.TP
236.B SO_BROADCAST
c13182ef
MK
237Set or get the broadcast flag.
238When enabled, datagram sockets
239receive packets sent to a broadcast address and they are allowed to send
ec4db3e7
MK
240packets to a broadcast address.
241This option has no effect on stream-oriented sockets.
242.TP
6b864085 243.B SO_BSDCOMPAT
c13182ef 244Enable BSD bug-to-bug compatibility.
6b864085
MK
245This is used by the UDP protocol module in Linux 2.0 and 2.2.
246If enabled ICMP errors received for a UDP socket will not be passed
c13182ef 247to the user program.
6b864085
MK
248In later kernel versions, support for this option has been phased out:
249Linux 2.4 silently ignores it, and Linux 2.6 generates a kernel warning
250(printk()) if a program uses this option.
c13182ef 251Linux 2.0 also enabled BSD bug-to-bug compatibility
6b864085 252options (random header changing, skipping of the broadcast flag) for raw
c13182ef 253sockets with this option, but that was removed in Linux 2.2.
6b864085 254.TP
c13182ef
MK
255.B SO_DEBUG
256Enable socket debugging.
257Only allowed for processes with the
ec4db3e7
MK
258.B CAP_NET_ADMIN
259capability or an effective user ID of 0.
260.TP
261.B SO_ERROR
c13182ef
MK
262Get and clear the pending socket error.
263Only valid as a
63f6a20a 264.BR getsockopt (2).
c13182ef 265Expects an integer.
ec4db3e7
MK
266.TP
267.B SO_DONTROUTE
268Don't send via a gateway, only send to directly connected hosts.
c13182ef 269The same effect can be achieved by setting the
ec4db3e7 270.B MSG_DONTROUTE
c13182ef 271flag on a socket
ec4db3e7 272.BR send (2)
c13182ef
MK
273operation.
274Expects an integer boolean flag.
fea681da
MK
275.TP
276.B SO_KEEPALIVE
c13182ef
MK
277Enable sending of keep-alive messages on connection-oriented sockets.
278Expects an integer boolean flag.
fea681da 279.TP
ec4db3e7 280.B SO_LINGER
c13182ef
MK
281Sets or gets the
282.B SO_LINGER
283option.
284The argument is a
285.I linger
ec4db3e7
MK
286structure.
287.sp
288.in +0.25i
289.nf
290struct linger {
291 int l_onoff; /* linger active */
292 int l_linger; /* how many seconds to linger for */
293};
294.fi
295.in -0.25i
296.IP
c13182ef 297When enabled, a
ec4db3e7
MK
298.BR close (2)
299or
300.BR shutdown (2)
301will not return until all queued messages for the socket have been
c13182ef
MK
302successfully sent or the linger timeout has been reached.
303Otherwise,
ec4db3e7
MK
304the call returns immediately and the closing is done in the background.
305When the socket is closed as part of
306.BR exit (2),
307it always lingers in the background.
308.TP
fea681da 309.B SO_OOBINLINE
c13182ef
MK
310If this option is enabled,
311out-of-band data is directly placed into the receive data stream.
312Otherwise out-of-band data is only passed when the
313.B MSG_OOB
314flag is set during receiving.
fea681da
MK
315.\" don't document it because it can do too much harm.
316.\".B SO_NO_CHECK
317.TP
ec4db3e7
MK
318.B SO_PASSCRED
319Enable or disable the receiving of the
320.B SCM_CREDENTIALS
c13182ef
MK
321control message.
322For more information see
323.BR unix (7).
ec4db3e7
MK
324.TP
325.B SO_PEERCRED
c13182ef 326Return the credentials of the foreign process connected to this socket.
ec4db3e7 327This is only possible for connected
c13182ef 328.B PF_UNIX
ec4db3e7 329stream sockets and
c13182ef 330.B PF_UNIX
ec4db3e7 331stream and datagram socket pairs created using
c13182ef
MK
332.BR socketpair (2);
333see
334.BR unix (7).
ec4db3e7
MK
335The returned credentials are those that were in effect at the time
336of the call to
337.BR connect (2)
338or
339.BR socketpair (2).
340Argument is a
c13182ef
MK
341.I ucred
342structure.
343Only valid as a
63f6a20a 344.BR getsockopt (2).
ec4db3e7
MK
345.TP
346.B SO_PRIORITY
c13182ef 347Set the protocol-defined priority for all packets to be sent on
ec4db3e7 348this socket.
c13182ef
MK
349Linux uses this value to order the networking queues:
350packets with a higher priority may be processed first depending
351on the selected device queueing discipline.
ec4db3e7
MK
352For
353.BR ip (7),
c13182ef 354this also sets the IP type-of-service (TOS) field for outgoing packets.
ec4db3e7
MK
355Setting a priority outside the range 0 to 6 requires the
356.B CAP_NET_ADMIN
357capability.
358.TP
6b864085 359.B SO_RCVBUF
c13182ef
MK
360Sets or gets the maximum socket receive buffer in bytes.
361The kernel doubles this value (to allow space for bookkeeping overhead)
6b864085
MK
362when it is set using
363.\" Most (all?) other implementations do not do this -- MTK, Dec 05
63f6a20a 364.BR setsockopt (2),
6b864085 365and this doubled value is returned by
63f6a20a 366.BR getsockopt (2).
c13182ef
MK
367The default value is set by the
368.B rmem_default
369sysctl and the maximum allowed value is set by the
6b864085 370.B rmem_max
c13182ef 371sysctl.
6b864085
MK
372The minimum (doubled) value for this option is 256.
373.TP
374.BR SO_RCVBUFFORCE " (since Linux 2.6.14")
375Using this socket option, a privileged
376.RB ( CAP_NET_ADMIN )
c13182ef 377process can perform the same task as
6b864085 378.BR SO_RCVBUF ,
c13182ef 379but the
6b864085
MK
380.B rmem_max
381limit can be overridden.
382.TP
fea681da
MK
383.BR SO_RCVLOWAT " and " SO_SNDLOWAT
384Specify the minimum number of bytes in the buffer until the socket layer
c13182ef
MK
385will pass the data to the protocol
386.RB ( SO_SNDLOWAT )
387or the user on receiving
fea681da 388.RB ( SO_RCVLOWAT ).
d9bfdb9c 389These two values are initialized to 1.
f8b8dd88 390.B SO_SNDLOWAT
c13182ef 391is not changeable on Linux
f8b8dd88
MK
392.RB ( setsockopt
393fails with the error
394.BR ENOPROTOOPT ).
395.BR SO_RCVLOWAT
396is changeable
397only since Linux 2.4.
d994d579
MK
398The
399.BR select (2)
400and
401.BR poll (2)
402system calls currently do not respect the
403.B SO_RCVLOWAT
404setting on Linux,
405and mark a socket readable when even a single byte of data is available.
c13182ef 406A subsequent read from the socket will block until
d994d579
MK
407.BR SO_RCVLOWAT
408bytes are available.
fb8959ea 409.\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=111049368106984&w=2
d994d579 410.\" Tested on kernel 2.6.14 -- mtk, 30 Nov 05
fea681da
MK
411.TP
412.BR SO_RCVTIMEO " and " SO_SNDTIMEO
413.\" Not implemented in 2.0.
414.\" Implemented in 2.1.11 for getsockopt: always return a zero struct.
415.\" Implemented in 2.3.41 for setsockopt, and actually used.
416Specify the receiving or sending timeouts until reporting an error.
3df83977
MK
417The parameter is a
418.IR "struct timeval" .
fea681da
MK
419If an input or output function blocks for this period of time, and
420data has been sent or received, the return value of that function
421will be the amount of data transferred; if no data has been transferred
8729177b 422and the timeout has been reached then \-1 is returned with
fea681da
MK
423.I errno
424set to EAGAIN or EWOULDBLOCK
425.\" in fact to EAGAIN
426just as if the socket was specified to be nonblocking.
427If the timeout is set to zero (the default)
428then the operation will never timeout.
429.TP
fea681da 430.B SO_REUSEADDR
c13182ef
MK
431Indicates that the rules used in validating addresses supplied in a
432.BR bind (2)
433call should allow reuse of local addresses.
434For
fea681da
MK
435.B PF_INET
436sockets this
437means that a socket may bind, except when there
438is an active listening socket bound to the address.
439When the listening socket is bound to
440.B INADDR_ANY
441with a specific port then it is not possible
442to bind to this port for any local address.
443.TP
c13182ef
MK
444.B SO_SNDBUF
445Sets or gets the maximum socket send buffer in bytes.
446The kernel doubles this value (to allow space for bookkeeping overhead)
17805f5b
MK
447when it is set using
448.\" Most (all?) other implementations do not do this -- MTK, Dec 05
63f6a20a 449.BR setsockopt (2),
17805f5b 450and this doubled value is returned by
63f6a20a 451.BR getsockopt (2).
c13182ef
MK
452The default value is set by the
453.B wmem_default
454sysctl and the maximum allowed value is set by the
fea681da 455.B wmem_max
c13182ef 456sysctl.
17805f5b 457The minimum (doubled) value for this option is 2048.
fea681da 458.TP
bdca4aea
MK
459.BR SO_SNDBUFFORCE " (since Linux 2.6.14")
460Using this socket option, a privileged
461.RB ( CAP_NET_ADMIN )
c13182ef 462process can perform the same task as
594a37e7 463.BR SO_SNDBUF ,
c13182ef 464but the
bdca4aea
MK
465.B wmem_max
466limit can be overridden.
467.TP
7b5c3d0a
MK
468.B SO_TIMESTAMP
469Enable or disable the receiving of the
470.B SO_TIMESTAMP
c13182ef 471control message.
7199370f 472The timestamp control message is sent with level
7b5c3d0a 473.B SOL_SOCKET
c13182ef
MK
474and the
475.I cmsg_data
476field is a
7b5c3d0a
MK
477.I "struct timeval"
478indicating the
479reception time of the last packet passed to the user in this call.
480See
481.BR cmsg (3)
482for details on control messages.
ec4db3e7
MK
483.TP
484.B SO_TYPE
c13182ef
MK
485Gets the socket type as an integer (like
486.BR SOCK_STREAM ).
ec4db3e7 487Can only be read
c13182ef 488with
63f6a20a 489.BR getsockopt (2).
2b2581ee 490.SS Signals
fea681da 491When writing onto a connection-oriented socket that has been shut down
c13182ef 492(by the local or the remote end)
fea681da 493.B SIGPIPE
c13182ef 494is sent to the writing process and
fea681da 495.B EPIPE
c13182ef 496is returned.
fea681da
MK
497The signal is not sent when the write call
498specified the
c13182ef 499.B MSG_NOSIGNAL
fea681da
MK
500flag.
501.PP
c13182ef
MK
502When requested with the
503.B FIOSETOWN
63f6a20a 504.BR fcntl (2)
c13182ef
MK
505or
506.B SIOCSPGRP
63f6a20a 507.BR ioctl (2),
c13182ef
MK
508.B SIGIO
509is sent when an I/O event occurs.
510It is possible to use
fea681da 511.BR poll (2)
c13182ef 512or
fea681da
MK
513.BR select (2)
514in the signal handler to find out which socket the event occurred on.
515An alternative (in Linux 2.2) is to set a realtime signal using the
516.B F_SETSIG
63f6a20a 517.BR fcntl (2);
1e321034 518the handler of the real time signal will be called with
fea681da
MK
519the file descriptor in the
520.I si_fd
c13182ef 521field of its
fea681da 522.IR siginfo_t .
c13182ef 523See
fea681da
MK
524.BR fcntl (2)
525for more information.
526.PP
75b94dc3 527Under some circumstances (e.g., multiple processes accessing a
56185b42 528single socket), the condition that caused the
fea681da
MK
529.B SIGIO
530may have already disappeared when the process reacts to the signal.
c13182ef 531If this happens, the process should wait again because Linux
56185b42 532will resend the signal later.
2b2581ee 533.\" .SS Ancillary Messages
8d548bfe 534.SS Sysctls
c13182ef
MK
535The core socket networking sysctls can be accessed using the
536.I /proc/sys/net/core/*
537files or with the
538.BR sysctl (2)
539interface.
fea681da
MK
540.TP
541.B rmem_default
542contains the default setting in bytes of the socket receive buffer.
543.TP
544.B rmem_max
545contains the maximum socket receive buffer size in bytes which a user may
c13182ef 546set by using the
fea681da 547.B SO_RCVBUF
c13182ef 548socket option.
fea681da
MK
549.TP
550.B wmem_default
551contains the default setting in bytes of the socket send buffer.
552.TP
553.B wmem_max
554contains the maximum socket send buffer size in bytes which a user may
c13182ef 555set by using the
fea681da 556.B SO_SNDBUF
c13182ef 557socket option.
fea681da 558.TP
c13182ef 559.BR message_cost " and " message_burst
fea681da
MK
560configure the token bucket filter used to load limit warning messages
561caused by external network events.
562.TP
c13182ef 563.B netdev_max_backlog
fea681da
MK
564Maximum number of packets in the global input queue.
565.TP
566.B optmem_max
c13182ef
MK
567Maximum length of ancillary data and user control data like the iovecs
568per socket.
fea681da 569.\" netdev_fastroute is not documented because it is experimental
2b2581ee 570.SS Ioctls
c13182ef 571These operations can be accessed using
fea681da
MK
572.BR ioctl (2):
573
87866492 574.in +0.25i
fea681da
MK
575.nf
576.IB error " = ioctl(" ip_socket ", " ioctl_type ", " &value_result ");"
577.fi
87866492 578.in -0.25i
fea681da
MK
579.TP
580.B SIOCGSTAMP
c13182ef
MK
581Return a
582.I struct timeval
583with the receive timestamp of the last packet passed to the user.
584This is useful for accurate round trip time measurements.
585See
586.BR setitimer (2)
587for a description of
8478ee02 588.IR "struct timeval" .
fea681da 589.\"
7199370f 590This ioctl should only be used if the socket option
7b5c3d0a 591.B SO_TIMESTAMP
c13182ef 592is not set on the socket.
7199370f
MK
593Otherwise, it returns the timestamp of the
594last packet that was received while
7b5c3d0a 595.B SO_TIMESTAMP
7199370f 596was not set, or it fails if no such packet has been received,
c13182ef 597(i.e.,
63f6a20a 598.BR ioctl (2)
c13182ef
MK
599returns \-1 with
600.I errno
601set to
7199370f 602.BR ENOENT ).
fea681da
MK
603.TP
604.BR SIOCSPGRP
c13182ef 605Set the process or process group to send
fea681da 606.B SIGIO
c13182ef 607or
fea681da 608.B SIGURG
c13182ef 609signals
fea681da
MK
610to when an
611asynchronous I/O operation has finished or urgent data is available.
c13182ef
MK
612The argument is a pointer to a
613.BR pid_t .
614If the argument is positive, send the signals to that process.
615If the
357cf3fe 616argument is negative, send the signals to the process group with the ID
fea681da
MK
617of the absolute value of the argument.
618The process may only choose itself or its own process group to receive
619signals unless it has the
620.B CAP_KILL
621capability or an effective UID of 0.
622.TP
623.B FIOASYNC
624Change the
625.B O_ASYNC
c13182ef 626flag to enable or disable asynchronous I/O mode of the socket.
a28e26a1 627Asynchronous I/O mode means that the
c13182ef
MK
628.B SIGIO
629signal or the signal set with
fea681da
MK
630.B F_SETSIG
631is raised when a new I/O event occurs.
632.IP
c13182ef 633Argument is an integer boolean flag.
fea681da
MK
634.\"
635.TP
636.BR SIOCGPGRP
637Get the current process or process group that receives
c13182ef
MK
638.B SIGIO
639or
fea681da 640.B SIGURG
c13182ef 641signals,
fea681da 642or 0
c13182ef 643when none is set.
fea681da 644.PP
1e321034 645Valid
63f6a20a 646.BR fcntl (2)
1e321034 647operations:
fea681da 648.TP
c13182ef
MK
649.BR FIOGETOWN
650The same as the SIOCGPGRP
63f6a20a 651.BR ioctl (2).
fea681da
MK
652.TP
653.BR FIOSETOWN
c13182ef 654The same as the SIOCSPGRP
63f6a20a 655.BR ioctl (2).
2b2581ee
MK
656.SH VERSIONS
657.B SO_BINDTODEVICE
658was introduced in Linux 2.0.30.
659.B SO_PASSCRED
660is new in Linux 2.2.
661The sysctls are new in Linux 2.2.
662.B SO_RCVTIMEO
663and
664.B SO_SNDTIMEO
665are supported since Linux 2.3.41.
666Earlier, timeouts were fixed to
667a protocol specific setting, and could not be read or written.
fea681da
MK
668.SH NOTES
669Linux assumes that half of the send/receive buffer is used for internal
670kernel structures; thus the sysctls are twice what can be observed
671on the wire.
672
673Linux will only allow port re-use with the SO_REUSEADDR option
c13182ef 674when this option was set both in the previous program that performed a
63f6a20a 675.BR bind (2)
b5cc2ffb 676to the port and in the program that wants to re-use the port.
fea681da
MK
677This differs from some implementations (e.g., FreeBSD)
678where only the later program needs to set the SO_REUSEADDR option.
679Typically this difference is invisible, since, for example, a server
680program is designed to always set this option.
681.SH BUGS
c13182ef
MK
682The
683.B CONFIG_FILTER
684socket options
685.B SO_ATTACH_FILTER
686and
687.B SO_DETACH_FILTER
688are
689not documented.
690The suggested interface to use them is via the libpcap
fea681da 691library.
fea681da
MK
692.\" .SH AUTHORS
693.\" This man page was written by Andi Kleen.
694.SH "SEE ALSO"
695.BR getsockopt (2),
696.BR setsockopt (2),
697.BR socket (2),
698.BR capabilities (7),
699.BR ddp (7),
700.BR ip (7),
701.BR packet (7)