getsockopt.2 (2010 09)
g
getsockopt(2) getsockopt(2)
NAME
getsockopt(), setsockopt() - get and set options on sockets
SYNOPSIS
#include <sys/socket.h>
int getsockopt(
int s,
int level,
int optname,
void *optval,
int *optlen
);
int setsockopt(
int s,
int level,
int optname,
const void *optval,
int optlen
);
UNIX 03 Only (X/Open Sockets)
int getsockopt(
int s,
int level,
int optname,
void *__restrict optval,
socklen_t *__restrict optlen
);
int setsockopt(
int s,
int level,
int optname,
const void *optval,
socklen_t optlen
);
Obsolescent UNIX 95 Only (X/Open Sockets)
int getsockopt(
int s,
int level,
int optname,
void *optval,
size_t *optlen
);
int setsockopt(
int s,
int level,
int optname,
const void *optval,
size_t optlen
);
DESCRIPTION
The getsockopt() and setsockopt() system calls manipulate options associated with a socket.
The socket is identified by the socket descriptor s. Options can exist at multiple protocol levels, and they
are always present at the uppermost "socket" level (see socket (2)).
When manipulating socket options, the level at which the option resides (level ) and the name of the
option (optname ) must be specified. To manipulate options at the "socket" level, level is specified as
SOL_SOCKET. To specify options at another level, level should be the protocol number specified in
<netinet/in.h> (for example, IPPROTO_TCP).
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1