Manual Page Result
0
Command: getsockopt | Section: 2 | Source: Digital UNIX | File: getsockopt.2.gz
getsockopt(2) System Calls Manual getsockopt(2)
NAME
getsockopt - Gets socket options
SYNOPSIS
#include <sys/socket.h>
int getsockopt (
int socket, int level, int option_nam, void *op-
tion_value, size_t *option_len );
[Digital] The following definition of the getsockopt() function does
not conform to current standards and is supported only for backward
compatibility (see standards(5)):
int getsockopt (
int socket, int level, int option_nam, char *op-
tion_value, int *option_len );
STANDARDS
Interfaces documented on this reference page conform to industry stan-
dards as follows:
getsockopt(): XPG4-UNIX
Refer to the standards(5) reference page for more information about in-
dustry standards and associated tags.
PARAMETERS
Specifies the unique socket name. Specifies the protocol level at
which the option resides. To retrieve options at the socket level,
specify the level parameter as SOL_SOCKET. 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 protocol, set level to the protocol number of
TCP, as defined in the netinet/in.h header file, or as determined by
using the getprotobyname() function. Specifies a single option to be
retrieved. The socket level options can be enabled or disabled by the
setsockopt() function. The getsockopt() function retrieves information
about the following options: Reports whether debugging information is
being recorded. This option returns an int value. Reports whether
socket listening is enabled. This option returns an int value. Re-
ports whether transmission of broadcast messages is supported. This
option returns an int value. Reports whether the rules used in vali-
dating addresses supplied by a bind() function should allow reuse of
local addresses. This option returns an int value. Reports whether
connections are kept active with periodic transmission of messages. If
the connected socket fails to respond to these messages, the connection
is broken and processes using that socket are notified with a SIGPIPE
signal. This option returns an int value. Reports whether outgoing
messages should bypass the standard routing facilities. (Not recom-
mended, for debugging purposes only.) This option returns an int
value. Only valid for routing sockets. Reports whether the sender re-
ceives a copy of each message. This option returns an int value. Re-
ports whether the socket lingers on a close() function if data is
present. If SO_LINGER is set, the system blocks the process during the
close() function until it can transmit the data or until the time ex-
pires. If SO_LINGER is not specified, and a close() function is is-
sued, the system handles the call in a way that allows the process to
continue as quickly as possible. This option returns an struct linger
value. Reports whether the socket leaves received out-of-band data
(data marked urgent) in line. This option returns an int value. Re-
ports send buffer size information. This option returns an int value.
Reports receive buffer size information. This option returns an int
value. [Digital] Reports send low-water mark information. This option
returns an int value. [Digital] Reports receive low-water mark infor-
mation. This option returns an int value. [Digital] Reports send
time-out information. This option returns a struct timeval value.
[Digital] Reports receive time-out information. This option returns a
struct timeval value. Reports information about error status and
clear. This option returns an int value. Reports the socket type.
This option returns an int value.
[Digital] Options at other protocol levels vary in format and name.
See the tcp(7) and ip(7) reference pages for more information on option
names relevant for TCP and IP options respectively.
Note
[Digital] The default values for socket level options like
SO_SENDBUF, SO_RCVBUF, SO_SNDLOWAT, and SO_RCVLOWAT are not con-
stant across different protocols and implementations. Use the
getsockopt(2) routine to obtain the default values programmati-
cally.
The address of a buffer. Specifies the length of buffer pointed
to by option_value. The option_len parameter initially contains
the size of the buffer pointed to by the option_value parameter.
On return, the option_len parameter is modified to indicate the
actual size of the value returned. If no option value is sup-
plied or returned, the option_value parameter can be 0 (zero).
Options at other protocol levels vary in format and name.
DESCRIPTION
The getsockopt() function allows an application program to query socket
options. The calling program specifies the name of the socket, the
name of the option, and a place to store the requested information.
The operating system gets the socket option information from its inter-
nal data structures and passes the requested information back to the
calling program.
Options may exist at multiple protocol levels. They are always present
at the uppermost socket level. When retrieving socket options, specify
the level at which the option resides and the name of the option.
RETURN VALUES
Upon successful completion, the getsockopt() function returns a value
of 0 (zero). Otherwise, a value of -1 is returned, and errno is set to
indicate the error.
ERRORS
If the getsockopt() function fails, errno may be set to one of the fol-
lowing values: The socket parameter is not valid. The address pointed
to by the option_value parameter is not in a valid (writable) part of
the process space, or the option_len parameter is not in a valid part
of the process address space. The socket has been shut down. The op-
tion is unknown. The socket parameter refers to a file, not a socket.
The operation is not supported by the socket protocol.
RELATED INFORMATION
Functions: bind(2), close(2), endprotoent(3), getprotobynumber(3), get-
protoent(3), setprotoent(3), setsockopt(2), socket(2)
Network Information: ip(7), tcp(7)
Standards: standards(5) delim off
getsockopt(2)