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