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