aboutsummaryrefslogtreecommitdiff
path: root/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.md
blob: 9a5457fa5ce78654de4d7273b0b6c4bdaf490d2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_MAXCONNECTS
Section: 3
Source: libcurl
See-also:
  - CURLMOPT_MAX_HOST_CONNECTIONS (3)
  - CURLOPT_MAXCONNECTS (3)
---

# NAME

CURLMOPT_MAXCONNECTS - size of connection cache

# SYNOPSIS

~~~c
#include <curl/curl.h>

CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long max);
~~~

# DESCRIPTION

Pass a long indicating the **max**. The set number is used as the maximum
amount of simultaneously open connections that libcurl may keep in its
connection cache after completed use. By default libcurl enlarges the size for
each added easy handle to make it fit 4 times the number of added easy
handles.

By setting this option, you can prevent the cache size from growing beyond the
limit set by you.

When the cache is full, curl closes the oldest one in the cache to prevent the
number of open connections from increasing.

This option is for the multi handle's use only, when using the easy interface
you should instead use the CURLOPT_MAXCONNECTS(3) option.

See CURLMOPT_MAX_TOTAL_CONNECTIONS(3) for limiting the number of active
connections.

# DEFAULT

See DESCRIPTION

# PROTOCOLS

All

# EXAMPLE

~~~c
int main(void)
{
  CURLM *m = curl_multi_init();
  /* only keep 10 connections in the cache */
  curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);
}
~~~

# AVAILABILITY

Added in 7.16.3

# RETURN VALUE

Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.