1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLMOPT_MAX_TOTAL_CONNECTIONS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLMOPT_MAXCONNECTS (3)
9  - CURLMOPT_MAX_HOST_CONNECTIONS (3)
10---
11
12# NAME
13
14CURLMOPT_MAX_TOTAL_CONNECTIONS - max simultaneously open connections
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_TOTAL_CONNECTIONS,
22                            long amount);
23~~~
24
25# DESCRIPTION
26
27Pass a long for the **amount**. The set number is used as the maximum number
28of simultaneously open connections in total using this multi handle. For each
29new session, libcurl might open a new connection up to the limit set by
30CURLMOPT_MAX_TOTAL_CONNECTIONS(3). When the limit is reached, new
31sessions are held pending until there are available connections. If
32CURLMOPT_PIPELINING(3) is enabled, libcurl can try multiplexing if the
33host is capable of it.
34
35When more transfers are added to the multi handle than what can be performed
36due to the set limit, they get queued up waiting for their chance. When that
37happens, the CURLOPT_TIMEOUT_MS(3) timeout is counted inclusive of the
38waiting time, meaning that if you set a too narrow timeout in such a case the
39transfer might never even start before it times out.
40
41Even in the queued up situation, the CURLOPT_CONNECTTIMEOUT_MS(3)
42timeout is however treated as a per-connect timeout.
43
44# DEFAULT
45
46The default value is 0, which means that there is no limit. It is then simply
47controlled by the number of easy handles added.
48
49# PROTOCOLS
50
51All
52
53# EXAMPLE
54
55~~~c
56int main(void)
57{
58  CURLM *m = curl_multi_init();
59  /* never do more than 15 connections */
60  curl_multi_setopt(m, CURLMOPT_MAX_TOTAL_CONNECTIONS, 15L);
61}
62~~~
63
64# AVAILABILITY
65
66Added in 7.30.0
67
68# RETURN VALUE
69
70Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
71