GNURLOPT_TCP_NODELAY(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

Okay bestie, welcome to GNURLOPT_TCP_NODELAY(3) β€” this page lives in the curl_easy_setopt options manual, and it's literally all about one tiny TCP switch. Buckle up, it's giving networking but make it cute. πŸ¦‹


✨ NAME ✨

CURLOPT_TCP_NODELAY β€” set the TCP_NODELAY option. That's the whole vibe. πŸŽ€

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_NODELAY, long
nodelay);

✨ DESCRIPTION ✨

Pass a long specifying whether the TCP_NODELAY option is to be set or cleared (1L = set, 0 = clear). The option is set by default, bestie. πŸ’…

⚠️ Timing tea: this will have no effect after the connection has been established. So like, do it before the connection is already out the door, okay? 😭

Setting this option to 1L will disable TCP's Nagle algorithm on this connection. The purpose of this algorithm is to try to minimize the number of small packets on the network β€” and yes, "small packets" means TCP segments less than the Maximum Segment Size (MSS) for the network. 🧚

Maximizing the amount of data sent per TCP segment is good because it amortizes the overhead of the send. However, in some cases small segments may need to be sent without delay. This is less efficient than sending larger amounts of data at a time, and can contribute to congestion on the network if overdone. No cap, don't overdo it. πŸ”₯

πŸ’– DEFAULT πŸ’–

1 β€” she's set by default, periodt. ✨

🌈 PROTOCOLS 🌈

All β€” every protocol, bestie. All of 'em. πŸ‘‘

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  /* disable Nagle */
  curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 0);
  curl_easy_perform(curl);
}

πŸ¦‹ AVAILABILITY πŸ¦‹

Always. The default was changed to 1 from 0 in 7.50.2. Iconic little glow-up behavior. πŸ’…

⭐ RETURN VALUE ⭐

Returns CURLE_OK β€” that's the good one, bestie. 🫢

🌸 SEE ALSO 🌸


Signed, sealed, slayed: libcurl 7.50.0, dated 30 Jun 2016, and the manual page is GNURLOPT_TCP_NODELAY(3). Mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from