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