1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLMOPT_MAX_HOST_CONNECTIONS 5Section: 3 6Source: libcurl 7See-also: 8 - CURLMOPT_MAXCONNECTS (3) 9 - CURLMOPT_MAX_TOTAL_CONNECTIONS (3) 10Protocol: 11 - All 12Added-in: 7.30.0 13--- 14 15# NAME 16 17CURLMOPT_MAX_HOST_CONNECTIONS - max number of connections to a single host 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_HOST_CONNECTIONS, 25 long max); 26~~~ 27 28# DESCRIPTION 29 30Pass a long to indicate **max**. The set number is used as the maximum amount 31of simultaneously open connections to a single host (a host being the same as 32a hostname + port number pair). For each new session to a host, libcurl might 33open a new connection up to the limit set by CURLMOPT_MAX_HOST_CONNECTIONS(3). 34When the limit is reached, new sessions are kept pending until a connection 35becomes available. 36 37The default **max** value is 0, unlimited. This set limit is also used for 38proxy connections, and then the proxy is considered to be the host for which 39this limit counts. 40 41When more transfers are added to the multi handle than what can be performed 42due to the set limit, they are queued up waiting for their chance. When that 43happens, the CURLOPT_TIMEOUT_MS(3) timeout is inclusive of the waiting time, 44meaning that if you set a too narrow timeout in such a case the transfer might 45never even start before it times out. 46 47Even in the queued up situation, the CURLOPT_CONNECTTIMEOUT_MS(3) timeout is 48however treated as a per-connect timeout. 49 50Changing this value when there are transfers in progress is possible, and the 51new value is then used the next time checks are performed. Lowering the value 52does however not close down any active transfers, it simply does not allow new 53ones to get made. 54 55# DEFAULT 56 570 58 59# %PROTOCOLS% 60 61# EXAMPLE 62 63~~~c 64int main(void) 65{ 66 CURLM *m = curl_multi_init(); 67 /* do no more than 2 connections per host */ 68 curl_multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L); 69} 70~~~ 71 72# %AVAILABILITY% 73 74# RETURN VALUE 75 76Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. 77