Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getsockopt(3xnet) [sunos man page]

getsockopt(3XNET)				   X/Open Networking Services Library Functions 				 getsockopt(3XNET)

NAME
getsockopt - get the socket options SYNOPSIS
cc [ flag... ] file... -lxnet [ library... ] #include <sys/socket.h> int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len); DESCRIPTION
The getsockopt() function retrieves the value for the option specified by the option_name argument for the socket specified by the socket argument. If the size of the option value is greater than option_len, the value stored in the object pointed to by the option_value argu- ment will be silently truncated. Otherwise, the object pointed to by the option_len 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 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 (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(3XNET) function. The socket in use might require the process to have appropriate privileges to use the getsockopt() function. The option_name argument specifies a single option to be retrieved. It can be one of the following values defined in <sys/socket.h>: SO_DEBUG Reports whether debugging information is being recorded. This option stores an int value. This is a boolean option. SO_ACCEPTCONN Reports whether socket listening is enabled. This option stores an int value. SO_BROADCAST Reports whether transmission of broadcast messages is supported, if this is supported by the protocol. This option stores an int value. This is a boolean option. SO_REUSEADDR Reports whether the rules used in validating addresses supplied to bind(3XNET) should allow reuse of local addresses, if this is supported by the protocol. This option stores an int value. This is a boolean option. SO_KEEPALIVE Reports whether connections are kept active with periodic transmission of messages, if this is supported by the protocol. If the connected socket fails to respond to these messages, the connection is broken and threads writing to that socket are notified with a SIGPIPE signal. This option stores an int value. This is a boolean option. SO_LINGER Reports whether the socket lingers on close(2) if data is present. If SO_LINGER is set, the system blocks the process during close(2) until it can transmit the data or until the end of the interval indicated by the l_linger member, whichever comes first. If SO_LINGER is not specified, and close(2) is issued, the system handles the call in a way that allows the process to continue as quickly as possible. This option stores a linger structure. SO_OOBINLINE Reports whether the socket leaves received out-of-band data (data marked urgent) in line. This option stores an int value. This is a boolean option. SO_SNDBUF Reports send buffer size information. This option stores an int value. SO_RCVBUF Reports receive buffer size information. This option stores an int value. SO_ERROR Reports information about error status and clears it. This option stores an int value. SO_TYPE Reports the socket type. This option stores an int value. SO_DONTROUTE Reports whether outgoing messages bypass the standard routing facilities. The destination must be on a directly- connected network, and messages are directed to the appropriate network interface according to the destination address. The effect, if any, of this option depends on what protocol is in use. This option stores an int value. This is a boolean option. For boolean options, a zero value indicates that the option is disabled and a non-zero value indicates that the option is enabled. Options at other protocol levels vary in format and name. The socket in use may require the process to have appropriate privileges to use the getsockopt() function. RETURN VALUES
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 descriptor. EFAULT The option_value or option_len parameter can not be accessed or written. EINVAL The specified option is invalid at the specified socket level. ENOPROTOOPT The option is not supported by the protocol. ENOTSOCK The socket argument does not refer to a socket. The getsockopt() function may fail if: EACCES The calling process does not have the appropriate privileges. 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 available for the operation to complete. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
close(2), bind(3XNET), endprotoent(3XNET), setsockopt(3XNET), socket(3XNET), attributes, standards(5) SunOS 5.10 10 Dec 2003 getsockopt(3XNET)
Man Page