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

NAME

6       CURLOPT_TCP_KEEPALIVE - TCP keep-alive probing
7

SYNOPSIS

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

DESCRIPTION

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

DEFAULT

21       0
22

PROTOCOLS

24       All
25

EXAMPLE

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

AVAILABILITY

44       Added in 7.25.0
45

RETURN VALUE

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

SEE ALSO

51       CURLOPT_TCP_KEEPIDLE(3), CURLOPT_TCP_KEEPINTVL(3),
52
53
54
55libcurl 7.85.0                   May 17, 2022         CURLOPT_TCP_KEEPALIVE(3)
Impressum