setsockopt

Name

setsockopt -- set socket options

Synopsis

#include <sys/socket.h>
#include <netinet/ip.h>

int setsockopt(int socket, int level, int option_name, const void * option_value, socklen_t option_len);

Description

The setsockopt() function shall behave as specified in ISO POSIX (2003), with the following extensions.

IP Protocol Level Options

If the level parameter is IPPROTO_IP, the following values shall be supported for option_name (see RFC 791:Internet Protocol for further details):

IP_OPTIONS 

Set the Internet Protocol options sent with every packet from this socket. The option_value shall point to a memory buffer containing the options and option_len shall contain the size in bytes of that buffer. For IPv4, the maximum length of options is 40 bytes.

IP_TOS 

Set the Type of Service flags to use when sending packets with this socket. The option_value shall point to a value containing the type of service value. The least significant two bits of the value shall contain the new Type of Service indicator. Use of other bits in the value is unspecified. The option_len parameter shall hold the size, in bytes, of the buffer referred to by option_value.

IP_TTL 

Set the current unicast Internet Protocol Time To Live value used when sending packets with this socket. The option_value shall point to a value containing the time to live value, which shall be between 1 and 255. The option_len parameter shall hold the size, in bytes, of the buffer referred to by option_value.