setsockopt(2) DG/UX R4.11MU05 setsockopt(2)
NAME
setsockopt - set options on sockets
SYNOPSIS
#include <sys/socket.h>
int setsockopt (s, level, optname, optval, optlen)
int s;
int level;
int optname;
const void * optval;
int optlen;
where:
s File descriptor of socket to set options on
level Level in socket that the options apply to (e.g., socket
level, implementing protocol level)
optname Name of options to set
optval Value associated with option
optlen Length of option to set (bytes)
DESCRIPTION
The setsockopt call sets options associated with a socket. Options
may exist at multiple protocol levels; they are always present at the
uppermost socket level.
When setting socket options, the caller must specify the level at
which the option resides and the name of the option. 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. See
documentation for the domain being used.
The parameters optval and optlen supply option values for setsockopt.
If no option value is to be supplied, optlen must be supplied as 0
and optval may be undefined.
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; see
socket(2). Options at other protocol levels vary in format and name;
consult the related domain documentation.
Socket Level Options
This is a list of the options recognized at the socket level:
SO_DEBUG Toggles debugging in the underlying protocol modules.
optval is a pointer to on/off flag int.
SO_REUSEADDR Toggles the indication that the rules used in
validating addresses supplied in a bind(2) call shall
allow reuse of local addresses. optval is a pointer
to on/off flag int.
SO_KEEPALIVE Toggles the periodic transmission of messages on a
connected socket. Should the connected peer fail to
respond to these messages, the connection is
considered broken and processes using the socket are
notified via a SIGPIPE signal. optval is a pointer to
on/off flag int.
SO_DONTROUTE Toggles the indication that outgoing messages shall
bypass the standard routing facilities. Instead,
messages are directed to the appropriate network
interface according to the network portion of the
destination address. optval is a pointer to on/off
flag int.
SO_LINGER Controls the action taken when unsent messages are
queued on the socket and a close(2) is performed. If
linger is reset (default), the close returns
immediatly, but the socket persists until all the data
is delivered or the connection is lost. If linger is
set, the system will block the process on close(2)
until all the data is sent or until the linger timeout
expires. A linger timeout of zero will cause the
system to reset the connection and discard unsent
data. optval is a pointer to struct linger.
SO_BROADCAST Toggles permission to send broadcast datagrams on the
socket. optval is a pointer to on/off flag int.
SO_OOBINLINE With protocols that support out-of-band data, the
option toggles the request that out-of-band data be
placed in the normal data input queue as received; it
will then be accessible with recv(2) or read(2) calls
without the MSG_OOB flag. optval is a pointer to
on/off flag int.
SO_SNDBUF Adjusts the normal buffer sizes allocate for output
buffers. optval is a pointer to int containing the
size of send buffer.
SO_RCVBUF Adjust the normal buffer sizes allocated for input
buffers. optval is a pointer to int containing the
size of receive buffer.
SO_TYPE Used only with getsockopt(2) to return the type of the
socket. optval is a pointer to int containing the
socket type.
SO_ERROR Used only with getsockopt(2). It returns any pending
error on the socket and clears the error status.
optval is a pointer to int containing errno.
ACCESS CONTROL
Consult domain documentation for any specific restrictions imposed by
the domain. SOL_SOCKET has no restrictions.
RETURN VALUE
0 Completed successfully.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
Errno may be set to one of the following error codes:
EBADF The argument s is not an active valid descriptor.
ENOTSOCK The argument 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.
EINVAL Invalid argument.
ENOBUFS No internal buffers available.
EOPNOTSUPP The option is unsupported.
EISCONN The option is invalid while the socket is in the
connected state.
EACCES Caller has inadequate privileges to set the option.
Socket privilege is based on the euid of the process
when the socket was created.
SEE ALSO
getsockopt(2), socket(2), inet(3N), inet(6F), unixipc(6F).
Licensed material--property of copyright holder(s)