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