1--- 2c: Copyright (C) Daniel Stenberg, <daniel.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) 12--- 13 14# NAME 15 16CURLOPT_TCP_KEEPALIVE - TCP keep-alive probing 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPALIVE, long probe); 24~~~ 25 26# DESCRIPTION 27 28Pass a long. If set to 1, TCP keepalive probes are used. The delay and 29frequency of these probes can be controlled by the 30CURLOPT_TCP_KEEPIDLE(3) and CURLOPT_TCP_KEEPINTVL(3) options, 31provided the operating system supports them. Set to 0 (default behavior) to 32disable keepalive probes 33 34# DEFAULT 35 360 37 38# PROTOCOLS 39 40All 41 42# EXAMPLE 43 44~~~c 45int 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 /* 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 curl_easy_perform(curl); 61 } 62} 63~~~ 64 65# AVAILABILITY 66 67Added in 7.25.0 68 69# RETURN VALUE 70 71Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 72