COHERENT manpages
This page displays the COHERENT manpage for setsockopt() [Set a socket option].
List of available manpages
Index
setsockopt() -- Sockets Function (libsocket)
Set a socket option
#include <sys/types.h>
#include <sys/socket.h>
int setsockopt(socket, level, option, buffer, length)
int socket, level, option, length;
char *buffer;
Function setsockopt() sets options on a socket.
socket gives the identifier of the socket, as returned by the function
socket().
level gives the level at which the options are set. To retrieve options
set on the socket level, set level to SOL_SOCKET whereas to retrieve
options set the TCP level, set level to the number of the TCP protocol.
option gives the number of the option to set. A list of options that are
recognized at the socket level appears below. Options at other levels are
set by their respective protocols.
buffer gives the address of the buffer that holds the option. length gives
the length of buffer, in bytes.
The following options are recognized at the socket level. They are set in
header file <sys/socket.h>:
SO_BROADCAST
Toggle permission to transmit broadcast messages.
SO_KEEPALIVE
Toggle whether to keep a connection alive by periodically transmitting
messages. If the connected party fails to respond to a message, the
connection is considered broken and processes that use the socket are
notified via the signal SIGPIPE.
SO_LINGER
Control the action taken when a socket is closed but contains unsent
messages. If SO_LINGER is set and the socket promises reliable
delivery of data, the system blocks the process that is attempting to
close socket until socket can transmit its data or its attempts to do
so time out. If SO_LINGER is not enabled, the socket is closed
immediately and the unsent messages are thrown away.
SO_OOBINLINE
Toggle whether a band can receive out-of-band data. Such data can
then be read by the function recv() or sent by the function send(),
when invoked with the flag MSG_OOB.
SO_RCVBUF
SO_SNDBUF
Set the size of the receive or send buffer, respectively. You can
increase the size of a buffer to speed high-volume connections, or
decrease it to limit the amount of data that are backlogged. The
system places an absolute limit on these values.
SO_REUSEADDR
Toggle whether local addresses can be reused.
If all goes well, setsockopt() returns zero. If something goes wrong, it
returns -1 and set errno to one of the following values:
EBADF
socket does not identify a valid socket.
ENOMEM
The available user memory was insufficient to complete the operation.
ENOPROTOOPT
option gives an unknown option.
ENOTSOCK
socket identifies a file, not a socket.
See Also
getsockopt(),
libsocket