1CURLOPT_MAXCONNECTS(3) curl_easy_setopt options CURLOPT_MAXCONNECTS(3)
2
3
4
6 CURLOPT_MAXCONNECTS - maximum connection cache size
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXCONNECTS, long amount);
12
14 Pass a long. The set amount will be the maximum number of simultane‐
15 ously open persistent connections that libcurl may cache in the pool
16 associated with this handle. The default is 5, and there is not much
17 point in changing this value unless you are perfectly aware of how this
18 works and changes libcurl's behavior. This concerns connections using
19 any of the protocols that support persistent connections.
20
21 When reaching the maximum limit, curl closes the oldest one in the
22 cache to prevent increasing the number of open connections.
23
24 If you already have performed transfers with this curl handle, setting
25 a smaller CURLOPT_MAXCONNECTS(3) than before may cause open connections
26 to get closed unnecessarily.
27
28 If you add this easy handle to a multi handle, this setting is not ac‐
29 knowledged, and you must instead use curl_multi_setopt(3) and the CURL‐
30 MOPT_MAXCONNECTS(3) option.
31
33 5
34
36 Most
37
39 CURL *curl = curl_easy_init();
40 if(curl) {
41 CURLcode ret;
42 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
43 /* limit the connection cache for this handle to no more than 3 */
44 curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
45 ret = curl_easy_perform(curl);
46 }
47
49 Always
50
52 Returns CURLE_OK
53
55 CURLMOPT_MAXCONNECTS(3), CURLOPT_MAXREDIRS(3),
56
57
58
59libcurl 8.0.1 January 02, 2023 CURLOPT_MAXCONNECTS(3)