1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_TCP_KEEPALIVE 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_LOW_SPEED_LIMIT (3) 9 - CURLOPT_MAX_RECV_SPEED_LARGE (3) 10 - CURLOPT_TCP_KEEPIDLE (3) 11 - CURLOPT_TCP_KEEPINTVL (3) 12Protocol: 13 - All 14--- 15 16# NAME 17 18CURLOPT_TCP_KEEPALIVE - TCP keep-alive probing 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPALIVE, long probe); 26~~~ 27 28# DESCRIPTION 29 30Pass a long. If set to 1, TCP keepalive probes are used. The delay and 31frequency of these probes can be controlled by the 32CURLOPT_TCP_KEEPIDLE(3) and CURLOPT_TCP_KEEPINTVL(3) options, 33provided the operating system supports them. Set to 0 (default behavior) to 34disable keepalive probes 35 36# DEFAULT 37 380 39 40# EXAMPLE 41 42~~~c 43int main(void) 44{ 45 CURL *curl = curl_easy_init(); 46 if(curl) { 47 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 48 49 /* enable TCP keep-alive for this transfer */ 50 curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); 51 52 /* keep-alive idle time to 120 seconds */ 53 curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); 54 55 /* interval time between keep-alive probes: 60 seconds */ 56 curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); 57 58 curl_easy_perform(curl); 59 } 60} 61~~~ 62 63# AVAILABILITY 64 65Added in 7.25.0 66 67# RETURN VALUE 68 69Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 70