1CURLOPT_MAXLIFETIME_CONN(3)curl_easy_setopt optionsCURLOPT_MAXLIFETIME_CONN(3)
2
3
4

NAME

6       CURLOPT_MAXLIFETIME_CONN  -  max  lifetime (since creation) allowed for
7       reusing a connection
8

SYNOPSIS

10       #include <curl/curl.h>
11
12       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXLIFETIME_CONN,
13                                 long maxlifetime);
14

DESCRIPTION

16       Pass a long as parameter containing maxlifetime - the maximum  time  in
17       seconds, since the creation of the connection, that you allow an exist‐
18       ing connection to have to be considered for reuse for this request.
19
20       libcurl features a connection cache that holds previously used  connec‐
21       tions.   When a new request is to be done, it will consider any connec‐
22       tion that matches for reuse. The CURLOPT_MAXLIFETIME_CONN(3) limit pre‐
23       vents  libcurl  from  trying too old connections for reuse. This can be
24       used for client-side load balancing. If a connection is  found  in  the
25       cache  that  is  older  than  this  set maxlifetime, it will instead be
26       closed once any in-progress transfers complete.
27
28       If set to 0, this behavior is disabled: all  connections  are  eligible
29       for reuse.
30

DEFAULT

32       Default maxlifetime is 0 seconds (i.e., disabled).
33

PROTOCOLS

35       All
36

EXAMPLE

38       CURL *curl = curl_easy_init();
39       if(curl) {
40         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
41
42         /* only allow each connection to be reused for 30 seconds */
43         curl_easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 30L);
44
45         curl_easy_perform(curl);
46       }
47

AVAILABILITY

49       Added in 7.80.0
50

RETURN VALUE

52       Returns CURLE_OK.
53

SEE ALSO

55       CURLOPT_TIMEOUT(3),  CURLOPT_FORBID_REUSE(3), CURLOPT_FRESH_CONNECT(3),
56       CURLOPT_MAXAGE_CONN(3),
57
58
59
60libcurl 7.85.0                   May 17, 2022      CURLOPT_MAXLIFETIME_CONN(3)
Impressum