|
The setsockopt() function sets the option specified by the option_name argument, at the protocol level specified by the level
argument, to the value pointed to by the option_value argument for the socket associated with the file descriptor specified by the socket argument.
The level argument specifies the protocol level at which the option resides. To set options at the socket level, specify the level argument as
SOL_SOCKET. To set options at other levels, supply the appropriate protocol number for the protocol controlling the option. For example, to indicate that an option will be interpreted by the TCP (Transport
Control Protocol), set level to the protocol number of TCP, as defined in the<netinet/in.h> header, or as determined by using getprotobyname(3XNET).
The option_name argument specifies a single option to set. The option_name argument and any specified options are passed uninterpreted to the
appropriate protocol module for interpretations. The <sys/socket.h> header defines the socket level options. The options are as follows:
- SO_DEBUG
- Turns on recording of debugging information. This option enables or disables debugging in the underlying protocol modules. This option takes
an int value. This is a boolean option.
- SO_BROADCAST
- Permits sending of broadcast messages, if this is supported by the protocol. This option takes an int value. This is a boolean option.
- SO_REUSEADDR
- Specifies that the rules used in validating addresses supplied to bind(3XNET) should allow reuse of local addresses, if this is supported by the protocol. This option takes an int value. This is a boolean option.
- SO_KEEPALIVE
- Keeps connections active by enabling the periodic transmission of messages, if this is supported by the protocol. This option takes an int value.
If the connected socket fails to respond to these messages, the connection is broken and processes writing to that socket are notified with a SIGPIPE signal.
This is a boolean option.
- SO_LINGER
- Lingers on a close(2)
if data is present. This option controls the action taken when unsent messages queue on a socket and close(2) is performed. If SO_LINGER is set, the system blocks the process during close(2) until it can transmit the data or until the time expires. If SO_LINGER is not specified, and close(2) is issued, the system handles the call in a way that allows the process to continue as quickly as possible. This option
takes a linger structure, as defined in the <sys/socket.h> header, to specify the state of the option and linger interval.
- SO_OOBINLINE
- Leaves received out-of-band data (data marked urgent) in line. This option takes an int value. This is a boolean option.
- SO_SNDBUF
- Sets send buffer size. This option takes an int value.
- SO_RCVBUF
- Sets receive buffer size. This option takes an int value.
- SO_DONTROUTE
- Requests that outgoing messages bypass the standard routing facilities. The destination must be on a directly-connected network, and messages are
directed to the appropriate network interface according to the destination address. The effect, if any, of this option depends on what protocol is in use. This option takes an int
value. This is a boolean option.
For boolean options, 0 indicates that the option is disabled and 1 indicates that the option is enabled.
Options at other protocol levels vary in format and name.
|