1CURLOPT_TCP_KEEPALIVE(3)   curl_easy_setopt options   CURLOPT_TCP_KEEPALIVE(3)
2
3
4

NAME

6       CURLOPT_TCP_KEEPALIVE - enable TCP keep-alive probing
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode  curl_easy_setopt(CURL  *handle,  CURLOPT_TCP_KEEPALIVE,  long
12       probe);
13

DESCRIPTION

15       Pass a long. If set to 1, TCP keepalive probes will be sent. The  delay
16       and   frequency   of  these  probes  can  be  controlled  by  the  CUR‐
17       LOPT_TCP_KEEPIDLE(3) and CURLOPT_TCP_KEEPINTVL(3) options, provided the
18       operating  system supports them. Set to 0 (default behavior) to disable
19       keepalive probes
20

DEFAULT

22       0
23

PROTOCOLS

25       All
26

EXAMPLE

28       CURL *curl = curl_easy_init();
29       if(curl) {
30         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
31
32         /* enable TCP keep-alive for this transfer */
33         curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
34
35         /* keep-alive idle time to 120 seconds */
36         curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
37
38         /* interval time between keep-alive probes: 60 seconds */
39         curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
40
41         curl_easy_perform(curl);
42       }
43

AVAILABILITY

45       Added in 7.25.0
46

RETURN VALUE

48       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
49       if not.
50

SEE ALSO

52       CURLOPT_TCP_KEEPIDLE(3), CURLOPT_TCP_KEEPINTVL(3),
53
54
55
56libcurl 7.76.1                 November 04, 2020      CURLOPT_TCP_KEEPALIVE(3)
Impressum