1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_TCP_KEEPIDLE 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_TCP_KEEPALIVE (3) 9 - CURLOPT_TCP_KEEPINTVL (3) 10 - CURLOPT_TCP_KEEPCNT (3) 11Protocol: 12 - TCP 13Added-in: 7.25.0 14--- 15 16# NAME 17 18CURLOPT_TCP_KEEPIDLE - TCP keep-alive idle time wait 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay); 26~~~ 27 28# DESCRIPTION 29 30Pass a long. Sets the *delay*, in seconds, to wait while the connection is 31idle before sending keepalive probes. Not all operating systems support this 32option. 33 34The maximum value this accepts is 2147483648. Any larger value is capped to 35this amount. 36 37# DEFAULT 38 3960 40 41# %PROTOCOLS% 42 43# EXAMPLE 44 45~~~c 46int main(void) 47{ 48 CURL *curl = curl_easy_init(); 49 if(curl) { 50 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 51 52 /* enable TCP keep-alive for this transfer */ 53 curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); 54 55 /* set keep-alive idle time to 120 seconds */ 56 curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); 57 58 /* interval time between keep-alive probes: 60 seconds */ 59 curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); 60 61 /* maximum number of keep-alive probes: 3 */ 62 curl_easy_setopt(curl, CURLOPT_TCP_KEEPCNT, 3L); 63 64 curl_easy_perform(curl); 65 } 66} 67~~~ 68 69# %AVAILABILITY% 70 71# RETURN VALUE 72 73Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 74