1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_TCP_KEEPIDLE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_TCP_KEEPALIVE (3)
9  - CURLOPT_TCP_KEEPINTVL (3)
10---
11
12# NAME
13
14CURLOPT_TCP_KEEPIDLE - TCP keep-alive idle time wait
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay);
22~~~
23
24# DESCRIPTION
25
26Pass a long. Sets the *delay*, in seconds, to wait while the connection is
27idle before sending keepalive probes. Not all operating systems support this
28option.
29
30The maximum value this accepts is 2147483648. Any larger value is capped to
31this amount.
32
33# DEFAULT
34
3560
36
37# PROTOCOLS
38
39All
40
41# EXAMPLE
42
43~~~c
44int main(void)
45{
46  CURL *curl = curl_easy_init();
47  if(curl) {
48    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
49
50    /* enable TCP keep-alive for this transfer */
51    curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
52
53    /* set keep-alive idle time to 120 seconds */
54    curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
55
56    /* interval time between keep-alive probes: 60 seconds */
57    curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
58
59    curl_easy_perform(curl);
60  }
61}
62~~~
63
64# AVAILABILITY
65
66Added in 7.25.0
67
68# RETURN VALUE
69
70Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
71