getsockopt(3N-xs) (X/OPEN SOCKETS) getsockopt(3N-xs)
NAME
getsockopt - get the socket options
SYNOPSIS
cc [flag ...] file ... -lxnet [library ...]
#include <sys/socket.h>
int getsockopt(int socket, int level, int optionname,
void *optionvalue, sizet *optionlen);
DESCRIPTION
The getsockopt function retrieves the value for the option specified
by the optionname argument for the socket specified by the socket
argument. If the size of the option value is greater than optionlen,
the value stored in the object pointed to by the optionvalue argument
will be silently truncated. Otherwise, the object pointed to by the
optionlen argument will be modified to indicate the actual length of
the value.
The level argument specifies the protocol level at which the option
resides. To retrieve options at the socket level, specify the level
argument as SOLSOCKET. To retrieve options at other levels, supply
the appropriate protocol number for the protocol controlling the
option. For example, to indicate that an option will be interpreted by
the TCP (Transport Control Protocol), set level to the protocol number
of TCP, as defined in the <netinet/in.h> header, or as determined by
using getprotobyname function.
The optionname argument specifies a single option to be retrieved. It
can be one of the following values defined in <sys/socket.h>:
SODEBUG Reports whether debugging information is being
recorded. This option stores an int value.
SOACCEPTCONN Reports whether socket listening is enabled. This
option stores an int value.
SOBROADCAST Reports whether transmission of broadcast messages
is supported, if this is supported by the proto-
col. This option stores an int value.
SOREUSEADDR Reports whether the rules used in validating
addresses supplied to bind should allow reuse of
local addresses, if this is supported by the pro-
tocol. This option stores an int value.
Page 1 Reliant UNIX 5.44 Printed 11/98
getsockopt(3N-xs) (X/OPEN SOCKETS) getsockopt(3N-xs)
SOKEEPALIVE Reports whether connections are kept active with
periodic transmission of messages, if this is sup-
ported by the protocol.
If the connected socket fails to respond to these
messages, the connection is broken and processes
writing to that socket are notified with a SIGPIPE
signal. This option stores an int value.
SOLINGER Reports whether the socket lingers on close if
data is present. If SOLINGER is set, the system
blocks the process during close until it can
transmit the data or until the end of the interval
indicated by the llinger member, whichever comes
first. If SOLINGER is not specified, and close is
issued, the system handles the call in a way that
allows the process to continue as quickly as pos-
sible. This option stores a linger structure.
SOOOBINLINE Reports whether the socket leaves received out-
of-band data (data marked urgent) in line. This
option stores an int value.
SOSNDBUF Reports send buffer size information. This option
stores an int value.
SORCVBUF Reports receive buffer size information. This
option stores an int value.
SOERROR Reports information about error status and clears
it. This option stores an int value.
SOTYPE Reports the socket type. This option stores an int
value. For boolean options, 0 indicates that the
option is disabled and 1 indicates that the option
is enabled. Options at other protocol levels vary
in format and name.
RETURN VALUE
Upon successful completion, getsockopt returns 0. Otherwise, -1 is
returned and errno is set to indicate the error.
ERRORS
The getsockopt function will fail if:
EBADF The socket argument is not a valid file descrip-
tor.
ENOPROTOOPT The option is not supported by the protocol.
ENOTSOCK The socket argument does not refer to a socket.
Page 2 Reliant UNIX 5.44 Printed 11/98
getsockopt(3N-xs) (X/OPEN SOCKETS) getsockopt(3N-xs)
EINVAL The specified option is invalid at the specified
socket level.
EOPNOTSUPP The operation is not supported by the socket pro-
tocol.
The getsockopt function may fail if:
EINVAL The socket has been shut down.
ENOBUFS Insufficient resources are available in the system
to complete the call.
ENOSR There were insufficient STREAMS resources avail-
able for the operation to complete.
SEE ALSO
close(2), bind(3N-xs), getprotoent(3N-xs), getsockopt(3N-xs),
socket(3N-xs), ip(7).
Page 3 Reliant UNIX 5.44 Printed 11/98