1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_TCP_KEEPCNT 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_TCP_KEEPALIVE (3) 9 - CURLOPT_TCP_KEEPIDLE (3) 10 - CURLOPT_TCP_KEEPINTVL (3) 11Protocol: 12 - TCP 13Added-in: 8.9.0 14--- 15 16# NAME 17 18CURLOPT_TCP_KEEPCNT - Maximum number of TCP keep-alive probes 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPCNT, long cnt); 26~~~ 27 28# DESCRIPTION 29 30Pass a long. Sets the number of probes to send before dropping 31the connection. Not all operating systems support this option. 32(Added in 8.9.0) 33 34The maximum value this option accepts is INT_MAX or whatever your 35system allows. 36Any larger value is capped to this amount. 37 38# DEFAULT 39 409 41 42# %PROTOCOLS% 43 44# EXAMPLE 45 46~~~c 47int 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 74Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 75