CURLOPT_TCP_FASTOPEN(3)

πŸ’… CURLOPT_TCP_FASTOPEN(3) πŸ’…

okay so we're in the Library Functions Manual, bestie, and today's main character is CURLOPT_TCP_FASTOPEN β€” the option that literally skips a whole round-trip like it's running late for class. ✨


🌸 NAME 🌸

CURLOPT_TCP_FASTOPEN β€” TCP Fast Open, no cap πŸš€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_FASTOPEN, long enable);

πŸ’– DESCRIPTION πŸ’–

So you pass a long as the parameter, and it's so simple: set it to 1L to turn it on, or 0 to turn it off. that's the whole vibe check. 🫢

TCP Fast Open (RFC 7413) is this iconic mechanism where data just... rides along inside the SYN and SYN-ACK packets, and the receiving end consumes it during the initial connection handshake. the result? it saves up to one full round-trip time (RTT). one. whole. RTT. that's giving main character energy honestly. ⭐

⚠️ Beware, bestie: the TLS session cache does not work when TCP Fast Open is enabled. like, at all. 😭 and TCP Fast Open is also known to be problematic on or across certain networks. so like... know before you go. πŸ’€

πŸŽ€ DEFAULT πŸŽ€

0

(off by default β€” she's lowkey until you tell her otherwise)


🌈 PROTOCOLS 🌈

This functionality affects tcp only. that's it. that's the whole list. periodt. πŸ’…


✨ EXAMPLE ✨

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
    curl_easy_perform(curl);
  }
}

look at her go πŸ”₯


🧚 NOTES 🧚

This option is only supported on Linux and macOS 10.11 or later. so if you're on something else… not me being unsupported πŸ™ˆ


πŸ‘‘ AVAILABILITY πŸ‘‘

Added in curl 7.49.0 β€” a classic, honestly. πŸŽ€


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK β€” slay. non-zero means an error occurred, so go check libcurl-errors(3) and figure out what went wrong, iykyk. 😭


🌸 SEE ALSO 🌸


and that's the page, bestie!! πŸ’– this one came from the libcurl crew, dated 2026-10-12 β€” mwah, kisses, go forth and fast-open responsibly. πŸ“πŸ’…πŸ«Ά

πŸ“¦ where this page comes from