Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (f - i) getsockopt(2)
DESCRIPTION
The getsockopt() function allows an application program to query socket options. The calling
program specifies the file descriptor, the option, and a place to store the requested information.
The operating system gets the socket option information from its internal data structures and
passes the requested information back to the calling program.
Upon successful completion, the getsockopt() function returns the value of the specified option
in the buffer pointed to by the option_value parameter. For options that can be classified as dis-
abled or enabled, a value of 0 (zero) indicates that the option is disabled and a value of 1 indi-
cates that the option is enabled. The socket-level options can be enabled or disabled by the set-
sockopt() function.
RETURN VALUES
Upon successful completion, the getsockopt() function returns the value 0 (zero). Otherwise,
the value -1 is returned and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the getsockopt() function sets errno to the
corresponding value:
[EBADF] The socket parameter is not a valid file descriptor.
[ECONNRESET]
One of the following conditions occurred:
• The transport-provider process for this socket is no longer available.
• The TCP/IP subsystem for this socket is no longer available.
• The connection was forcibly closed by the peer socket.
The socket can only be closed.
[EFAULT] A user-supplied memory buffer cannot be accessed or written.
[EINVAL] One of the following conditions occurred:
• The specified option is not valid at the specified socket level.
• The socket has been shut down.
[ENOBUFS] There was not enough buffer space available to complete the call. A retry at a
later time might succeed.
[ENOMEM] Required memory resources were not available. A retry at a later time might
succeed.
[ENOPROTOOPT]
The specified option is not supported by the protocol used by the socket.
[ENOTSOCK] The socket parameter does not refer to a socket.
[EOPNOTSUPP]
The specified operation is not supported by the protocol used by the socket.
RELATED INFORMATION
Functions: bind(2), close(2), endprotoent(3), getprotobynumber(3), getprotoent(3), setpro-
toent(3), setsockopt(2), socket(2), socketpair(2).
527186-003 Hewlett-Packard Company 3−55