CURLMOPT_MAXCONNECTS.md (1822B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLMOPT_MAXCONNECTS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLMOPT_MAX_HOST_CONNECTIONS (3) 9 - CURLOPT_MAXCONNECTS (3) 10 Protocol: 11 - All 12 Added-in: 7.16.3 13 --- 14 15 # NAME 16 17 CURLMOPT_MAXCONNECTS - size of connection cache 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long max); 25 ~~~ 26 27 # DESCRIPTION 28 29 Pass a long indicating the **max**, the maximum amount of connections that 30 libcurl may keep alive in its connection cache after use. By default libcurl 31 enlarges the size for each added easy handle to make it fit 4 times the number 32 of added easy handles. 33 34 By setting this option, you prevent the cache size from growing beyond the 35 limit set by you. 36 37 When the cache is full, curl closes the oldest connection present in the cache 38 to prevent the number of connections from increasing. 39 40 This option is for the multi handle's use only, when using the easy interface 41 you should instead use the CURLOPT_MAXCONNECTS(3) option. 42 43 See CURLMOPT_MAX_TOTAL_CONNECTIONS(3) for limiting the number of active 44 connections. 45 46 Changing this value when there are transfers in progress is possible, and the 47 new value is then used the next time checks are performed. Lowering the value 48 does not close down any active transfers, it simply does not allow new ones to 49 get made. 50 51 # DEFAULT 52 53 See DESCRIPTION 54 55 # %PROTOCOLS% 56 57 # EXAMPLE 58 59 ~~~c 60 int main(void) 61 { 62 CURLM *m = curl_multi_init(); 63 /* only keep 10 connections in the cache */ 64 curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L); 65 } 66 ~~~ 67 68 # %AVAILABILITY% 69 70 # RETURN VALUE 71 72 curl_multi_setopt(3) returns a CURLMcode indicating success or error. 73 74 CURLM_OK (0) means everything was OK, non-zero means an error occurred, see 75 libcurl-errors(3).