CURLMOPT_MAX_TOTAL_CONNECTIONS.md (2247B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLMOPT_MAX_TOTAL_CONNECTIONS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLMOPT_MAXCONNECTS (3) 9 - CURLMOPT_MAX_HOST_CONNECTIONS (3) 10 Protocol: 11 - All 12 Added-in: 7.30.0 13 --- 14 15 # NAME 16 17 CURLMOPT_MAX_TOTAL_CONNECTIONS - max simultaneously open connections 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, 25 long amount); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long for the **amount**. The set number is used as the maximum number 31 of simultaneously open connections in total using this multi handle. For each 32 new session, libcurl might open a new connection up to the limit set by 33 CURLMOPT_MAX_TOTAL_CONNECTIONS(3). If CURLMOPT_PIPELINING(3) is enabled, 34 libcurl can try multiplexing if the host is capable of it. 35 36 When more transfers are added to the multi handle than what can be performed 37 due to the set limit, they get queued up waiting for their chance. 38 39 While a transfer is queued up internally waiting for a connection, the 40 CURLOPT_TIMEOUT_MS(3) timeout is counted inclusive of the waiting time, 41 meaning that if you set a too narrow timeout the transfer might never even 42 start before it times out. The CURLOPT_CONNECTTIMEOUT_MS(3) time is also 43 similarly still treated as a per-connect timeout and might expire even before 44 making a new connection is permitted. 45 46 Changing this value while there are transfers in progress is possible. The new 47 value is then used the next time checks are performed. Lowering the value does 48 not close down any active transfers, it simply does not allow new ones to get 49 made. 50 51 # DEFAULT 52 53 0, which means that there is no limit. It is then simply controlled by the 54 number of easy handles added concurrently and how much multiplexing is being 55 done. 56 57 # %PROTOCOLS% 58 59 # EXAMPLE 60 61 ~~~c 62 int main(void) 63 { 64 CURLM *m = curl_multi_init(); 65 /* never do more than 15 connections */ 66 curl_multi_setopt(m, CURLMOPT_MAX_TOTAL_CONNECTIONS, 15L); 67 } 68 ~~~ 69 70 # %AVAILABILITY% 71 72 # RETURN VALUE 73 74 curl_multi_setopt(3) returns a CURLMcode indicating success or error. 75 76 CURLM_OK (0) means everything was OK, non-zero means an error occurred, see 77 libcurl-errors(3).