1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLMOPT_MAXCONNECTS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLMOPT_MAX_HOST_CONNECTIONS (3)
9  - CURLOPT_MAXCONNECTS (3)
10Protocol:
11  - All
12Added-in: 7.16.3
13---
14
15# NAME
16
17CURLMOPT_MAXCONNECTS - size of connection cache
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long max);
25~~~
26
27# DESCRIPTION
28
29Pass a long indicating the **max**, the maximum amount of connections that
30libcurl may keep alive in its connection cache after use. By default libcurl
31enlarges the size for each added easy handle to make it fit 4 times the number
32of added easy handles.
33
34By setting this option, you prevent the cache size from growing beyond the
35limit set by you.
36
37When the cache is full, curl closes the oldest connection present in the cache
38to prevent the number of connections from increasing.
39
40This option is for the multi handle's use only, when using the easy interface
41you should instead use the CURLOPT_MAXCONNECTS(3) option.
42
43See CURLMOPT_MAX_TOTAL_CONNECTIONS(3) for limiting the number of active
44connections.
45
46Changing this value when there are transfers in progress is possible, and the
47new value is then used the next time checks are performed. Lowering the value
48does not close down any active transfers, it simply does not allow new ones to
49get made.
50
51# DEFAULT
52
53See DESCRIPTION
54
55# %PROTOCOLS%
56
57# EXAMPLE
58
59~~~c
60int main(void)
61{
62  CURLM *m = curl_multi_init();
63  /* only keep 10 connections in the cache */
64  curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);
65}
66~~~
67
68# %AVAILABILITY%
69
70# RETURN VALUE
71
72Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
73