Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getsockopt(2) — Ultrix-11 3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

socket(2)

getprotoent(3n)

getsockopt(2)

NAME

getsockopt, setsockopt − get and set options on sockets

SYNTAX

#include <sys/types.h>
#include <sys/socket.h>

int getsockopt(s, level, optname, optval, optlen)
int s, level, optname, optlen;
char *optval;

int setsockopt(s, level, optname, optval, optlen)
int s, level, optname, optlen;
char *optval;

DESCRIPTION

The getsockopt and setsockopt system calls manipulate options associated with socket s. Options may exist at multiple protocol levels, but they are always present at the uppermost socket level. 

When manipulating socket options, the level at which the option resides and the name of the option must be specified.  To manipulate options at the socket level, level is specified as SOL_SOCKET.  To manipulate options at any other level, the protocol number of the appropriate protocol controlling the option is supplied.  For example, to indicate an option that is to be interpreted by the TCP protocol, level should be set to the protocol number of TCP.  For further information, see getprotoent(3n). 

The optval and optlen are used to access option values for setsockopt.  For the getsockopt call, they identify a buffer in which the value for the requested option(s) are to be returned.  For the getsockopt call, optlen is a value-result argument that initially contains the size of the buffer pointed to by optval but is modified on return to indicate the actual size of the value returned.  If no option value is to be supplied or returned, optval can be supplied as 0. 

The 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.  For further information, see socket(2).  Options at other protocol levels vary in format and name, see the appropriate entries in section(4p). 

RETURN VALUE

If unsuccessful, returns a −1, and the global variable errno indicates the error code. 

DIAGNOSTICS

The getsockopt and setsockopt calls will fail if:

[EBADF] The specified s is not a valid descriptor. 

[ENOTSOCK] The specified s is a file, not a socket. 

[ENOPROTOOPT] The option is unknown. 

[EFAULT] The options are not in a valid part of the process address space. 

SEE ALSO

socket(2), getprotoent(3n)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026