TCP Socket Options

Onload User Guide (UG1586)

Document ID
Release Date
1.2 English

Onload TCP supports the following socket options which can be used in the setsockopt() and getsockopt() function calls.

Table 1. Socket Options for setsockopt() and getsockopt()
Option Description
SO_PROTOCOL Retrieve the socket protocol as an integer.
SO_ACCEPTCONN Determines whether the socket can accept incoming connections - true for listening sockets. (Only valid as a getsockopt()).
SO_BINDTODEVICE Bind this socket to a particular network interface. See SO_BINDTODEVICE.
SO_CONNECT_TIME Number of seconds a connection has been established. (Only valid as a getsockopt()).
SO_DEBUG Enable protocol debugging.
SO_ERROR The errno value of the last error occurring on the socket. (Only valid as a getsockopt()).
SO_EXCLUSIVEADDRUSE Prevents other sockets using the SO_REUSEADDR option to bind to the same address and port.
SO_KEEPALIVE Enable sending of keep-alive messages on connection oriented sockets.
SO_LINGER When enabled, a close() or shutdown() will not return until all queued messages for the socket have been successfully sent or the linger timeout has been reached. Otherwise the close() or shutdown() returns immediately and sockets are closed in the background.
SO_OOBINLINE Indicates that out-of-band data should be returned in-line with regular data. This option is only valid for connection-oriented protocols that support out-of-band data.
SO_PRIORITY Set the priority for all packets sent on this socket. Packets with a higher priority might be processed first depending on the selected device queuing discipline.

Sets or gets the maximum socket receive buffer in bytes.

EF_TCP_RCVBUF overrides this value, and EF_TCP_RCVBUF_ESTABLISHED_DEFAULT can also override this value.

Setting SO_RCVBUF to a value < MTU can result in poorer performance and is not recommended.

SO_RCVLOWAT Sets the minimum number of bytes to process for socket input operations.
SO_RCVTIMEO Sets the timeout for input function to complete.
SO_RECVTIMEO Sets the timeout in milliseconds for blocking receive calls.
SO_REUSEADDR Can reuse local port numbers (another socket can bind to the same port) except when there is an active listening socket bound to the port.
SO_RESUSEPORT Allows multiple sockets to bind to the same port.

Sets or gets the maximum socket send buffer in bytes. The value set is doubled by the kernel and by Onload to allow for bookkeeping overhead when it is set by the setsockopt() function call.


When the EF_TCP_SNDBUF_MODE is set to 2, the SNDBUF size is automatically adjusted for each TCP socket to match the window advertised by the peer.

SO_SNDLOWAT Sets the minimum number of bytes to process for socket output operations. Always set to 1 byte.
SO_SNDTIMEO Set the timeout for sending function to send before reporting an error.
SO_TIMESTAMP Report timestamps from system clock in struct timeval.
SO_TIMESTAMPNS Report timestamps from system clock in struct timespec.
SO_TIMESTAMPING Enable/disable hardware timestamps for received packets.
SOF_TIMESTAMPING_TX_HARDWARE Obtain a hardware generated transmit timestamp.
SOF_TIMESTAMPING_SYS_HARDWARE Obtain a hardware transmit timestamp adjusted to the system time base.
SOF_TIMESTAMPING_OPT_CMSG Deliver timestamps using the cmsg API.
ONLOAD_SOF_TIMESTAMPING_STREAM Onload extension to the standard SO_TIMESTAMPING API to support hardware timestamps on TCP sockets.
SO_TYPE Returns the socket type (SOCK_STREAM or SOCK_DGRAM). (Only valid as a getsockopt()).
IP_TRANSPARENT This socket option allows the calling application to bind the socket to a nonlocal IP address.