BSD Sockets Interface Programmer's Guide
64 Chapter 3
Advanced Topics for Stream Sockets
Socket Options
• SO_RCVTIMEO
The following socket options toggle socket behavior. optval is an integer
containing a boolean flag for the behavior (1 = on, 0 = off):
• SO_KEEPALIVE
• SO_DEBUG
• SO_DONTROUTE
• SO_USELOOPBACK
• SO_REUSEADDR
• SO_OOBINLINE
• SO_REUSEPORT
The SO_LINGER option is a combination. It sets a linger value, and also
toggles linger behavior on and off. In previous releases
SO_DONTLINGER was supported. For SO_LINGER, optval points to a
struct linger, defined in /usr/include/sys/socket.h. The
structure contains an integer boolean flag to toggle behavior on/off, and
an integer linger value. Refer to the getsockopt(2) man page for more
information on getsockopt.
setsockopt and its parameters are described in the following table:
Include files: #include <sys/types.h>
#include <sys/socket.h>
System call: setsockopt(s, level, optname, optval, optlen)
int s, level, optname;
char *optval;
int optlen;
Parameter
Description of
Contents
INPUT Value
s socket descriptor socket descriptor for
which options are to be set
level protocol level SOL_SOCKET