getsockopt(2) DG/UX R4.11MU05 getsockopt(2)
NAME
getsockopt - get options on a socket
SYNOPSIS
#include <sys/socket.h>
int getsockopt (s, level, optname, optval, optlen)
int s;
int level;
int optname;
void * optval;
int * optlen;
where:
s File descriptor of socket to get options from
level Level in socket that the options apply to
optname Name of option to return (options are defined in socket.h)
optval Buffer to receive options
optlen On input contains the number of bytes available for the
options; updated to indicate the number of bytes returned
DESCRIPTION
Getsockopt retrieves options associated with a socket. Options may
exist at multiple protocol levels; they are always present at the
uppermost socket level.
When getting socket options, the caller must specify the level at
which the option resides and the name of the option. To retrieve
options at the socket level, level is specified as SOL_SOCKET. To
get options at any other level, the protocol number of the
appropriate protocol controlling the option is supplied. Consult
domain specific documentation for more information related to a
specific protocol.
The parameters optval and optlen identify a buffer in which the value
for the requested option(s) are to be returned. optlen is a
value/result parameter, initially containing the size of the buffer
pointed to by optval, and modified on return to indicate the actual
size of the value returned. If no option value is to be returned,
optval may be supplied as 0. If the buffer isn't large enough for
the options, they will be truncated.
Optname and any specified options are passed uninterpreted to the
appropriate protocol module for interpretation. The include file
<sys/socket.h> contains definitions for socket level options; see
socket. Options at other protocol levels vary in format and name;
consult the related documentation for the domain of the socket.
ACCESS CONTROL
SOL_SOCKET has no access restrictions. (See domain-specific
documentation for any domain restrictions.)
RETURN VALUE
0 Completed successfully.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
Errno may be set to one of the following error codes:
EBADF The argument s is not an active valid descriptor.
ENOTSOCK The argument s is not a file of type S_IFSOCK (socket
special).
ENOPROTOOPT The option is unknown.
EFAULT The optval is not in a valid part of the process
address space, or optlen < 0.
ENOBUFS No internal buffers available.
SEE ALSO
setsockopt(2), socket(2), inet(3N), inet(6F), tcp(6P), udp(6P),
unixipc(6F).
Licensed material--property of copyright holder(s)