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.
Printed 10/17/86 1
GETSOCKOPT(2) COMMAND REFERENCE GETSOCKOPT(2)
[ENOPROTOOPT]
The option specified in getsockopt is not set.
[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), getprotoent(3n).
Printed 10/17/86 2
%%index%%
na:72,91;
sy:163,1596;
de:1759,1916;
di:3675,245;4064,497;
rv:4561,406;
ca:4967,340;
se:5307,145;
%%index%%000000000131