1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_MAXCONNECTS 5Section: 3 6Source: libcurl 7See-also: 8 - CURLMOPT_MAXCONNECTS (3) 9 - CURLMOPT_MAX_HOST_CONNECTIONS (3) 10 - CURLMOPT_MAX_TOTAL_CONNECTIONS (3) 11 - CURLOPT_MAXREDIRS (3) 12Protocol: 13 - All 14Added-in: 7.7 15--- 16 17# NAME 18 19CURLOPT_MAXCONNECTS - maximum connection cache size 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25 26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXCONNECTS, long amount); 27~~~ 28 29# DESCRIPTION 30 31Pass a long. The set *amount* is the maximum number of connections that 32libcurl may keep alive in its connection cache after use. The default is 5, 33and there is not much point in changing this value unless you are perfectly 34aware of how this works. This concerns connections using any of the protocols 35that support persistent connections. 36 37When reaching the maximum limit, curl closes the oldest connection present in 38the cache to prevent the number of connections from increasing. 39 40If you already have performed transfers with this curl handle, setting a 41smaller CURLOPT_MAXCONNECTS(3) than before may cause open connections to get 42closed unnecessarily. 43 44If you add this easy handle to a multi handle, this setting is not 45acknowledged, and you must instead use curl_multi_setopt(3) and the 46CURLMOPT_MAXCONNECTS(3) option. 47 48# DEFAULT 49 505 51 52# %PROTOCOLS% 53 54# EXAMPLE 55 56~~~c 57int main(void) 58{ 59 CURL *curl = curl_easy_init(); 60 if(curl) { 61 CURLcode ret; 62 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 63 /* limit the connection cache for this handle to no more than 3 */ 64 curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L); 65 ret = curl_easy_perform(curl); 66 } 67} 68~~~ 69 70# %AVAILABILITY% 71 72# RETURN VALUE 73 74Returns CURLE_OK 75