GNURLOPT_TCP_KEEPIDLE(3)

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

okay bestie, welcome to GNURLOPT_TCP_KEEPIDLE(3) from the curl_easy_setopt options manual β€” the page about setting TCP keep-alive idle time wait. Yes, we're talking about how long the OS chills on an idle connection before it starts sending keepalive probes. Let's go πŸ’…βœ¨

🌸 NAME 🌸

CURLOPT_TCP_KEEPIDLE β€” set TCP keep-alive idle time wait. That's the whole assignment. πŸ’–

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long
delay);

πŸ¦‹ DESCRIPTION πŸ¦‹

You pass a long. That sets the delay, in seconds, that the operating system will wait while the connection is idle before sending keepalive probes.

⚠️ caveat, bestie: not all operating systems support this option. So if your OS doesn't have it, that's not a you problem β€” it's just not supported there. 🫢

πŸŽ€ DEFAULT πŸŽ€

Default is 60.

🌈 PROTOCOLS 🌈

All β€” every protocol, no cap. πŸ’―

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  /* enable TCP keep-alive for this transfer */
  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);

  /* set keep-alive idle time to 120 seconds */
  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);

  /* interval time between keep-alive probes: 60 seconds */
  curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);

  curl_easy_perform(curl);
}

πŸ‘‘ AVAILABILITY πŸ‘‘

Added in 7.25.0. It's been iconic for a minute. ✨

πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.

🧚 SEE ALSO 🧚

xoxo, from the libcurl 7.37.0 era, dated 19 Jun 2014 β€” and yes, this page is GNURLOPT_TCP_KEEPIDLE(3). πŸ’–πŸ«Ά

πŸ“¦ where this page comes from