GETSOCKOPT(2) COMMAND REFERENCE GETSOCKOPT(2) NAME getsockopt, setsockopt - get and set options on sockets SYNOPSIS #include <sys/types.h> #include <sys/socket.h> getsockopt(s, level, optname, optval, optlen) int s, level, optname; char *optval; int *optlen; setsockopt(s, level, optname, optval, optlen) int s, level, optname; char *optval; int optlen; DESCRIPTION Getsockopt and setsockopt manipulate options associated with a socket. To manipulate options at the ``socket'' level, level is specified as SOL_SOCKET. The parameters optval and optlen are used to specify option values for setsockopt. For getsockopt they identify a buffer in which the value for the requested option is to be returned. For getsockopt, optlen is a value-result parameter initially containing the size of the buffer pointed to by optval. It is modified on return to indicate the actual size of the value returned. If no option value is to be supplied or returned, optval may be supplied as 0. Optname and any specified option value are passed uninterpreted to the appropriate protocol module for interpretation. The include file <sys/socket.h> contains definitions for ``socket'' level options; see socket(2). At this level, optname is a single option; that is, only one option can be specified per call to getsockopt or setsockopt. Also, setsockopt will fail if an optval of size greater than the mbuf data length (defined in <sys/mbuf.h>) is specified. DIAGNOSTICS The call succeeds unless: [EBADF] The argument s is not a valid descriptor. [ENOTSOCK] The argument s is a file, not a socket. [ENOPROTOOPT] The option specified in getsockopt is not set. Printed 5/12/88 1
GETSOCKOPT(2) COMMAND REFERENCE GETSOCKOPT(2) [EINVAL] Optname or level is unknown; size of optval is too large (setsockopt). [EFAULT] The options are not in a valid part of the process address space. [ENOBUFS] No system buffer space is available. RETURN VALUE [0] Successful call. In the case of getsockopt, the option specified by optname is set. [-1] Unsuccessful call or optname is not set. An error code is stored into the global variable errno. CAVEATS At present, only ``socket'' level options are allowed. Of these, only SO_LINGER accepts an optval argument of integer size to setsockopt. There is no provision for resetting an option, once set. SEE ALSO socket(2) and getprotoent(3n). Printed 5/12/88 2
%%index%% na:384,107; sy:491,2460; de:2951,2280; di:5231,462;6149,403; rv:6552,484; ca:7036,408; se:7444,183; %%index%%000000000133