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