CURLMOPT_MAX_HOST_CONNECTIONS.3 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .\" generated by cd2nroff 0.1 from CURLMOPT_MAX_HOST_CONNECTIONS.md
  2. .TH CURLMOPT_MAX_HOST_CONNECTIONS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLMOPT_MAX_HOST_CONNECTIONS \- max number of connections to a single host
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_HOST_CONNECTIONS,
  9. long max);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a long to indicate \fBmax\fP. The set number is used as the maximum amount
  13. of simultaneously open connections to a single host (a host being the same as
  14. a hostname + port number pair). For each new session to a host, libcurl might
  15. open a new connection up to the limit set by \fICURLMOPT_MAX_HOST_CONNECTIONS(3)\fP.
  16. When the limit is reached, new sessions are kept pending until a connection
  17. becomes available.
  18. The default \fBmax\fP value is 0, unlimited. This set limit is also used for
  19. proxy connections, and then the proxy is considered to be the host for which
  20. this limit counts.
  21. When more transfers are added to the multi handle than what can be performed
  22. due to the set limit, they are queued up waiting for their chance. When that
  23. happens, the \fICURLOPT_TIMEOUT_MS(3)\fP timeout is inclusive of the waiting time,
  24. meaning that if you set a too narrow timeout in such a case the transfer might
  25. never even start before it times out.
  26. Even in the queued up situation, the \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP timeout is
  27. however treated as a per\-connect timeout.
  28. Changing this value when there are transfers in progress is possible, and the
  29. new value is then used the next time checks are performed. Lowering the value
  30. does however not close down any active transfers, it simply does not allow new
  31. ones to get made.
  32. .SH DEFAULT
  33. 0
  34. .SH PROTOCOLS
  35. This functionality affects all supported protocols
  36. .SH EXAMPLE
  37. .nf
  38. int main(void)
  39. {
  40. CURLM *m = curl_multi_init();
  41. /* do no more than 2 connections per host */
  42. curl_multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L);
  43. }
  44. .fi
  45. .SH AVAILABILITY
  46. Added in curl 7.30.0
  47. .SH RETURN VALUE
  48. Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
  49. .SH SEE ALSO
  50. .BR CURLMOPT_MAXCONNECTS (3),
  51. .BR CURLMOPT_MAX_TOTAL_CONNECTIONS (3)