CURLOPT_TCP_KEEPIDLE(3)
π€ CURLOPT_TCP_KEEPIDLE π€
okay so bestie, real talk: this is a libcurl thing β like, the manual name is CURLOPT_TCP_KEEPIDLE(3) and it lives in the curl library functions family, and it's literally the poster child for "how long do we just sit there before poking the server to check it's still alive."
πΈ NAME πΈ
CURLOPT_TCP_KEEPIDLE β the TCP keep-alive idle time wait. that's it. that's the vibe. π«Ά
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay);
π DESCRIPTION π
so you pass a long, right? and that long is the delay, measured in seconds, that curl waits while the connection is just sitting there doing nothing before it starts sending keepalive probes. think of it as the "how long do I let them leave me on read before I double-text" timer. π
β οΈ not every operating system supports this option, so don't come for curl if your OS is being a hater.
and about the number itself: the max value this accepts is 2147483648. anything bigger than that gets capped to that amount. no cap, that's literally the cap. π
π DEFAULT π
60
π¦ PROTOCOLS π¦
this functionality affects tcp only. tcp girlies only, sorry. π
π₯ EXAMPLE π₯
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://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);
/* maximum number of keep-alive probes: 3 */
curl_easy_setopt(curl, CURLOPT_TCP_KEEPCNT, 3L);
curl_easy_perform(curl);
}
}
like, look at her go. setting the idle time to 120 seconds, intervals of 60, max 3 probes. main character networking energy fr fr. π
β AVAILABILITY β
added in curl 7.25.0. she's been iconic since day one, we stan an OG. π
π§ RETURN VALUE π§
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (which is 0, bestie β zero is the good one here) means everything was OK. non-zero means an error occurred, and you should go see libcurl-errors(3) for the whole lore. π
πΈ SEE ALSO πΈ
π okay that's the whole page, you ate that. go forth and keep those connections alive.
mwah π β this page was brought to you by libcurl, dated 2026-10-12, and yes the title up top is CURLOPT_TCP_KEEPIDLE(3) in case you forgot already. byeeee πβ¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms