8 SYNOPSIS
9 cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
10 #include <sys/types.h>
11 #include <sys/socket.h>
12
13 int getsockopt(int s, int level, int optname, void *optval,
14 int *optlen);
15
16
17 int setsockopt(int s, int level, int optname, const void *optval,
18 int optlen);
19
20
21 DESCRIPTION
22 The getsockopt() and setsockopt() functions manipulate
23 options associated with a socket. Options may exist at mul-
24 tiple protocol levels; they are always present at the upper-
25 most "socket" level.
26
27
28 When manipulating socket options, the level at which the
29 option resides and the name of the option must be specified.
30 To manipulate options at the "socket" level, level is speci-
31 fied as SOL_SOCKET. To manipulate options at any other
32 level, level is the protocol number of the protocol that
33 controls the option. For example, to indicate that an option
34 is to be interpreted by the TCP protocol, level is set to
35 the TCP protocol number. See getprotobyname(3SOCKET).
36
37
38 The parameters optval and optlen are used to access option
39 values for setsockopt(). For getsockopt(), they identify a
40 buffer in which the value(s) for the requested option(s) are
41 to be returned. For getsockopt(), optlen is a value-result
42 parameter, initially containing the size of the buffer
43 pointed to by optval, and modified on return to indicate the
44 actual size of the value returned. Use a 0 optval if no
45 option value is to be supplied or returned.
46
47
48 The optname and any specified options are passed uninter-
49 preted to the appropriate protocol module for interpreta-
50 tion. The include file <sys/socket.h> contains definitions
51 for the socket-level options described below. Options at
52 other protocol levels vary in format and name.
53
54
55 Most socket-level options take an int for optval. For set-
|
8 SYNOPSIS
9 cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
10 #include <sys/types.h>
11 #include <sys/socket.h>
12
13 int getsockopt(int s, int level, int optname, void *optval,
14 int *optlen);
15
16
17 int setsockopt(int s, int level, int optname, const void *optval,
18 int optlen);
19
20
21 DESCRIPTION
22 The getsockopt() and setsockopt() functions manipulate
23 options associated with a socket. Options may exist at mul-
24 tiple protocol levels; they are always present at the upper-
25 most "socket" level.
26
27
28 The *level* argument specifies the protocol level at which
29 the option resides. To manipulate options at the socket
30 level, specify the *level* argument as *SOL_SOCKET*. To
31 manipulate options at the protocol level, supply the
32 appropriate protocol number for the protocol controlling the
33 option. For example, to indicate that an option will be
34 interpreted by TCP, set *level* to the protocol number of
35 TCP, as defined in the *<netinet/in.h>* header, or as
36 determined by using *getprotobyname(3SOCKET)*. Some socket
37 protocol families may also define additional levels, such as
38 *SOL_ROUTE*. Only socket-level options are described here.
39
40
41 The parameters optval and optlen are used to access option
42 values for setsockopt(). For getsockopt(), they identify a
43 buffer in which the value(s) for the requested option(s) are
44 to be returned. For getsockopt(), optlen is a value-result
45 parameter, initially containing the size of the buffer
46 pointed to by optval, and modified on return to indicate the
47 actual size of the value returned. Use a 0 optval if no
48 option value is to be supplied or returned.
49
50
51 The optname and any specified options are passed uninter-
52 preted to the appropriate protocol module for interpreta-
53 tion. The include file <sys/socket.h> contains definitions
54 for the socket-level options described below. Options at
55 other protocol levels vary in format and name.
56
57
58 Most socket-level options take an int for optval. For set-
|