Set options associated with a socket
int setsockopt( int s,
const void * optval,
socklen_t optlen );
- The file descriptor of the socket that the option is to be applied on,
as returned by
- The protocol layer that the option is to be applied to.
In most cases, it's a socket-level option and is indicated by SOL_SOCKET.
- The option for the socket file descriptor.
- A pointer to the value of the option (in most cases, whether the
option is to be turned on or off).
If no option value is to be returned, optval may be NULL.
Most socket-level options use an int parameter for optval.
Others, such as the SO_LINGER,
options, use structures that also let you get data associated with
- A pointer to the length of the value of the option.
This argument is a value-result parameter; you should initialize it
to indicate the size of the buffer pointed to by optval.
Use the -l socket option to
to link against this library.
The setsockopt() function sets the options associated with a socket.
for more detailed information.
- An error occurred (errno is set).
- Invalid file descriptor s.
- Value was set out of range.
- The address pointed to by optval isn't in a
valid part of the process address space.
- No optval value was specified.
- The option is unknown at the level indicated.