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