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). If CURLMOPT_PIPELINING(3) is enabled,
34libcurl can try multiplexing if the host is capable of it.
35
36When more transfers are added to the multi handle than what can be performed
37due to the set limit, they get queued up waiting for their chance.
38
39While a transfer is queued up internally waiting for a connection, the
40CURLOPT_TIMEOUT_MS(3) timeout is counted inclusive of the waiting time,
41meaning that if you set a too narrow timeout the transfer might never even
42start before it times out. The CURLOPT_CONNECTTIMEOUT_MS(3) time is also
43similarly still treated as a per-connect timeout and might expire even before
44making a new connection is permitted.
45
46Changing this value while there are transfers in progress is possible. The new
47value is then used the next time checks are performed. Lowering the value does
48not close down any active transfers, it simply does not allow new ones to get
49made.
50
51# DEFAULT
52
530, which means that there is no limit. It is then simply controlled by the
54number of easy handles added concurrently and how much multiplexing is being
55done.
56
57# %PROTOCOLS%
58
59# EXAMPLE
60
61~~~c
62int 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
74Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
75