1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" $Id: getsockopt.2,v 1.1 1999/05/24 14:57:04 freitag Exp $
34 .\" Modified Sat Jul 24 16:19:32 1993 by Rik Faith (faith@cs.unc.edu)
35 .\" Modified Mon Apr 22 02:29:06 1996 by Martin Schulze (joey@infodrom.north.de)
36 .\" Modified Tue Aug 27 10:52:51 1996 by Andries Brouwer (aeb@cwi.nl)
37 .\" Modified Thu Jan 23 13:29:34 1997 by Andries Brouwer (aeb@cwi.nl)
38 .\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer (aeb@cwi.nl)
39 .\" Modified 1999 by Andi Kleen <ak@muc.de>.
40 .\" Removed most stuff because it is in socket.7 now.
42 .TH GETSOCKOPT 2 1999-05-24 "Linux" "Linux Programmer's Manual"
44 getsockopt, setsockopt \- get and set options on sockets
47 .BR "#include <sys/types.h>" " /* See NOTES */"
49 .B #include <sys/socket.h>
51 .BI "int getsockopt(int " s ", int " level ", int " optname ,
52 .BI " void *" optval ", socklen_t *" optlen );
54 .BI "int setsockopt(int " s ", int " level ", int " optname ,
55 .BI " const void *" optval ", socklen_t " optlen );
63 associated with a socket.
64 Options may exist at multiple
65 protocol levels; they are always present at the uppermost
69 When manipulating socket options the level at which the
70 option resides and the name of the option must be specified.
71 To manipulate options at the socket level,
75 To manipulate options at any
76 other level the protocol number of the appropriate protocol
77 controlling the option is supplied.
79 to indicate that an option is to be interpreted by the
83 should be set to the protocol number of
92 are used to access option values for
96 they identify a buffer in which the value for the
97 requested option(s) are to be returned.
101 is a value-result parameter, initially containing the
102 size of the buffer pointed to by
104 and modified on return to indicate the actual size of
106 If no option value is to be supplied or returned,
111 and any specified options are passed uninterpreted to the appropriate
112 protocol module for interpretation.
115 contains definitions for socket level options, described below.
117 other protocol levels vary in format and name; consult the appropriate
118 entries in section 4 of the manual.
120 Most socket-level options utilize an
126 the parameter should be non-zero to enable a boolean option, or zero if the
127 option is to be disabled.
129 For a description of the available socket options see
131 and the appropriate protocol man pages.
133 On success, zero is returned.
134 On error, \-1 is returned, and
136 is set appropriately.
142 is not a valid descriptor.
145 The address pointed to by
147 is not in a valid part of the process address space.
150 this error may also be returned if
152 is not in a valid part of the process address space.
160 The option is unknown at the level indicated.
165 is a file, not a socket.
167 SVr4, 4.4BSD (these system calls first appeared in 4.2BSD),
169 .\" SVr4 documents additional ENOMEM and ENOSR error codes, but does
171 .\" .BR SO_SNDLOWAT ", " SO_RCVLOWAT ", " SO_SNDTIMEO ", " SO_RCVTIMEO
174 POSIX.1-2001 does not require the inclusion of
176 and this header file is not required on Linux.
177 However, some historical (BSD) implementations required this header
178 file, and portable applications are probably wise to include it.
188 (and this is what 4.x BSD and libc4 and libc5 have).
189 Some POSIX confusion resulted in the present
195 Several of the socket options should be handled at lower levels of the