set_tcp_socket_options()

set_tcp_socket_options()#

set_tcp_socket_options() configures TCP socket options such as TCP_NODELAY, SO_KEEPALIVE, and SO_LINGER for a given file descriptor.

Prototype

int set_tcp_socket_options(
    int fd,
    int delay
);

Parameters

Key

Type

Description

fd

int

The file descriptor of the TCP socket to configure.

delay

int

If nonzero, enables TCP_NODELAY to disable Nagle’s algorithm, reducing latency.


Return Value

Returns 0 on success, or -1 on failure.

Notes

This function is internally used for configuring TCP sockets in both client and server modes.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples