GNURLOPT_TCP_KEEPALIVE(3)
hey bestie π welcome to the curl_easy_setopt options manual β today's main character is GNURLOPT_TCP_KEEPALIVE(3). lowkey a tiny page, highkey useful if you want your TCP keepalive behavior to be your thing. no cap, let's go β¨
π NAME π
CURLOPT_TCP_KEEPALIVEβ enable TCP keep-alive probing π
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPALIVE, long
probe);
okay so you call curl_easy_setopt with your CURL *handle, pass the CURLOPT_TCP_KEEPALIVE option, and hand over a long probe value. that's the whole signature, periodt π«Ά
π DESCRIPTION π
Pass a long, bestie. If it's set to 1, TCP keepalive probes will be sent π₯. The delay and frequency of these probes can be controlled by the CURLOPT_TCP_KEEPIDLE(3) and CURLOPT_TCP_KEEPINTVL(3) options, provided the operating system supports them β iykyk. Set it to 0 (that's the default behavior) to disable keepalive probes. literally that simple, no notes π
π¦ DEFAULT π¦
0 β out of the box, keepalive probes are disabled. the default is giving "off" π
π PROTOCOLS π
All β every protocol, all of them, slay π
π EXAMPLE π
here's the exact little code moment from the page:
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);
/* 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);
}
that's it β iconic behavior π§
β AVAILABILITY β
Added in 7.25.0 β she's been here, and she ate π
π RETURN VALUE π
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. so if you get CURLE_UNKNOWN_OPTION, it's literally not supported β read the room π
π§ SEE ALSO π§
go peek at CURLOPT_TCP_KEEPIDLE(3), CURLOPT_TCP_KEEPINTVL(3), π
okay bye bestie! this page is from libcurl 7.37.0, dated 19 Jun 2014, and it's literally GNURLOPT_TCP_KEEPALIVE(3) β mwah πβ¨
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms