Rev | Author | # | Line |
---|---|---|---|
1 | perry | 1 | !!!GETSOCKOPT |
2 | !!NAME | ||
3 | |||
4 | getsockopt, setsockopt - get and set options on sockets | ||
5 | !!SYNOPSIS | ||
2 | PerryLorier | 6 | __#include <sys/types.h>__ |
7 | __#include <sys/socket.h>__ | ||
1 | perry | 8 | |
2 | PerryLorier | 9 | __int getsockopt(int__ ''s''__, int__ ''level''__, int__ ''optname''__, void *__''optval''__, socklen_t *__''optlen''__);__ |
1 | perry | 10 | |
2 | PerryLorier | 11 | __int setsockopt(int__ ''s''__, int__ ''level''__, int__ ''optname''__, const void *__''optval''__, socklen_t__ ''optlen''__);__ |
1 | perry | 12 | |
13 | !!DESCRIPTION | ||
14 | |||
15 | |||
16 | __Getsockopt__ and __setsockopt__ manipulate the | ||
17 | ''options'' associated with a socket. Options may exist | ||
18 | at multiple protocol levels; they are always present at the | ||
19 | uppermost __socket__ level. | ||
20 | |||
21 | |||
22 | When manipulating socket options the level at which the | ||
23 | option resides and the name of the option must be specified. | ||
24 | To manipulate options at the socket level, ''level'' is | ||
25 | specified as __SOL_SOCKET__. To manipulate options at any | ||
26 | other level the protocol number of the appropriate protocol | ||
27 | controlling the option is supplied. For example, to indicate | ||
28 | that an option is to be interpreted by the __TCP__ | ||
29 | protocol, ''level'' should be set to the protocol number | ||
30 | of __TCP__; see getprotoent(3). | ||
31 | |||
32 | |||
33 | The parameters ''optval'' and ''optlen'' are used to | ||
34 | access option values for __setsockopt__. For | ||
35 | __getsockopt__ they identify a buffer in which the value | ||
36 | for the requested option(s) are to be returned. For | ||
37 | __getsockopt__, ''optlen'' is a value-result | ||
38 | parameter, initially containing the size of the buffer | ||
39 | pointed to by ''optval'', and modified on return to | ||
40 | indicate the actual size of the value returned. If no option | ||
41 | value is to be supplied or returned, ''optval'' may be | ||
42 | NULL. | ||
43 | |||
44 | |||
45 | ''Optname'' and any specified options are passed | ||
46 | uninterpreted to the appropriate protocol module for | ||
47 | interpretation. The include file '''' | ||
48 | contains definitions for socket level options, described | ||
49 | below. Options at other protocol levels vary in format and | ||
50 | name; consult the appropriate entries in section 4 of the | ||
51 | manual. | ||
52 | |||
53 | |||
54 | Most socket-level options utilize an ''int'' parameter | ||
55 | for ''optval''. For __setsockopt__, the parameter | ||
56 | should be non-zero to enable a boolean option, or zero if | ||
57 | the option is to be disabled. | ||
58 | |||
59 | |||
60 | For a description of the available socket options see | ||
61 | socket(7) and the appropriate protocol man | ||
62 | pages. | ||
63 | !!RETURN VALUE | ||
64 | |||
65 | On success, zero is returned. On error, -1 is returned, and | ||
66 | ''errno'' is set appropriately. | ||
2 | PerryLorier | 67 | |
1 | perry | 68 | !!ERRORS |
2 | PerryLorier | 69 | ;[EBADF]: The argument ''s'' is not a valid descriptor. |
70 | ;[ENOTSOCK]: The argument ''s'' is a file, not a socket. | ||
71 | ;[ENOPROTOOPT]: The option is unknown at the level indicated. | ||
72 | ;[EFAULT]: The address pointed to by ''optval'' is not in a valid part of the process address space. For getsockopt(2), this error may also be returned if ''optlen'' is not in a valid part of the process address space. | ||
73 | ;[EINVAL]: The optlen or the option you are trying to set is invalid. | ||
3 | PerryLorier | 74 | ;[EADDRNOTAVAIL]: The level isn't applicable for this option. |
1 | perry | 75 | |
76 | !!CONFORMING TO | ||
2 | PerryLorier | 77 | SVr4, 4.4BSD (these system calls first appeared in 4.2BSD). SVr4 documents additional [ENOMEM] and [ENOSR] error codes, but does not document the __SO_SNDLOWAT__, __SO_RCVLOWAT__, __SO_SNDTIMEO__, __SO_RCVTIMEO__ options |
1 | perry | 78 | |
79 | !!NOTE | ||
2 | PerryLorier | 80 | The fifth argument of getsockopt(2) and setsockopt(2) is in reality an int [[*] (and this is what BSD 4.* and libc4 and libc5 have). Some [POSIX] confusion |
81 | resulted in the present socklen_t. The draft standard has not been adopted yet, but glibc2 already follows it and also has socklen_t [[*]. See also accept(2). | ||
1 | perry | 82 | |
83 | !!BUGS | ||
2 | PerryLorier | 84 | Several of the socket options should be handled at lower levels of the system. |
1 | perry | 85 | |
86 | !!SEE ALSO | ||
2 | PerryLorier | 87 | ioctl(2), socket(2), getprotoent(3), protocols(5), socket(7), unix(7), tcp(7) |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 9 times)