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 set number is used as the maximum
30amount of simultaneously open connections that libcurl may keep in its
31connection cache after completed use. By default libcurl enlarges the size for
32each added easy handle to make it fit 4 times the number of added easy
33handles.
34
35By setting this option, you can prevent the cache size from growing beyond the
36limit set by you.
37
38When the cache is full, curl closes the oldest one in the cache to prevent the
39number of open connections from increasing.
40
41This option is for the multi handle's use only, when using the easy interface
42you should instead use the CURLOPT_MAXCONNECTS(3) option.
43
44See CURLMOPT_MAX_TOTAL_CONNECTIONS(3) for limiting the number of active
45connections.
46
47Changing this value when there are transfers in progress is possible, and the
48new value is then used the next time checks are performed. Lowering the value
49does however not close down any active transfers, it simply does not allow new
50ones to get made.
51
52# DEFAULT
53
54See DESCRIPTION
55
56# %PROTOCOLS%
57
58# EXAMPLE
59
60~~~c
61int main(void)
62{
63  CURLM *m = curl_multi_init();
64  /* only keep 10 connections in the cache */
65  curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);
66}
67~~~
68
69# %AVAILABILITY%
70
71# RETURN VALUE
72
73Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
74