CURLOPT_TCP_KEEPIDLE.md (1582B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_TCP_KEEPIDLE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_TCP_KEEPALIVE (3) 9 - CURLOPT_TCP_KEEPINTVL (3) 10 - CURLOPT_TCP_KEEPCNT (3) 11 Protocol: 12 - TCP 13 Added-in: 7.25.0 14 --- 15 16 # NAME 17 18 CURLOPT_TCP_KEEPIDLE - TCP keep-alive idle time wait 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long. Sets the *delay*, in seconds, to wait while the connection is 31 idle before sending keepalive probes. Not all operating systems support this 32 option. 33 34 The maximum value this accepts is 2147483648. Any larger value is capped to 35 this amount. 36 37 # DEFAULT 38 39 60 40 41 # %PROTOCOLS% 42 43 # EXAMPLE 44 45 ~~~c 46 int 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 73 curl_easy_setopt(3) returns a CURLcode indicating success or error. 74 75 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 76 libcurl-errors(3).