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