Socket Options

Onload User Guide (UG1586)

Document ID
Release Date
1.2 English

Onload UDP 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_BINDTODEVICE bind this socket to a particular network interface. See SO_BINDTODEVICE.
SO_BROADCAST When enabled datagram sockets can send and receive packets to/from a broadcast address.
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_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 call returns immediately and sockets are closed in the background.
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_UDP_RCVBUF overrides 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_RECVTIMEO Sets the timeout for input function to complete.
SO_REUSEADDR Can reuse local ports (another socket can bind to the same port number) except when there is an active listening socket bound to the port.
SO_RESUSEPORT Allow 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.

EF_UDP_SNDBUF overrides this value.

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 Enable or disable receiving the SO_TIMESTAMP control message (microsecond resolution). See below.
SO_TIMESTAMPNS Enable or disable receiving the SO_TIMESTAMP control message (nanosecond resolution).
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.
SO_TYPE Returns the socket type (SOCK_STREAM or SOCK_DGRAM). (Only valid as a getsockopt()).