$linuxjunkies
>

TCP_NODELAY

also: TCP_NODELAY socket option

A socket option that disables Nagle's algorithm, causing data to be sent immediately rather than waiting to combine small packets for efficiency.

TCP_NODELAY is a socket option that controls whether the kernel buffers outgoing TCP data. When enabled, it overrides Nagle's algorithm, which normally waits for acknowledgments or buffers small packets to reduce network overhead.

By default, TCP uses Nagle's algorithm to batch small writes into fewer, larger packets. This reduces bandwidth waste but adds latency—each small message waits for acknowledgment before the next sends. With TCP_NODELAY set, every write goes out immediately, ideal for interactive applications like SSH or online games.

Example: setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)) disables buffering on a socket. A telnet session benefits from this because each keystroke should appear instantly, not wait for packet combining.

Related terms