CURLOPT_MAXCONNECTS.3 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLOPT_MAXCONNECTS.md
  2. .TH CURLOPT_MAXCONNECTS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_MAXCONNECTS \- maximum connection cache size
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXCONNECTS, long amount);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. The set \fIamount\fP is the maximum number of simultaneously open
  12. persistent connections that libcurl may cache in the pool associated with this
  13. handle. The default is 5, and there is not much point in changing this value
  14. unless you are perfectly aware of how this works. This concerns connections
  15. using any of the protocols that support persistent connections.
  16. When reaching the maximum limit, curl closes the oldest one in the cache to
  17. prevent increasing the number of open connections.
  18. If you already have performed transfers with this curl handle, setting a
  19. smaller \fICURLOPT_MAXCONNECTS(3)\fP than before may cause open connections to
  20. get closed unnecessarily.
  21. If you add this easy handle to a multi handle, this setting is not
  22. acknowledged, and you must instead use \fIcurl_multi_setopt(3)\fP and the
  23. \fICURLMOPT_MAXCONNECTS(3)\fP option.
  24. .SH DEFAULT
  25. 5
  26. .SH PROTOCOLS
  27. This functionality affects all supported protocols
  28. .SH EXAMPLE
  29. .nf
  30. int main(void)
  31. {
  32. CURL *curl = curl_easy_init();
  33. if(curl) {
  34. CURLcode ret;
  35. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  36. /* limit the connection cache for this handle to no more than 3 */
  37. curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
  38. ret = curl_easy_perform(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.7
  44. .SH RETURN VALUE
  45. Returns CURLE_OK
  46. .SH SEE ALSO
  47. .BR CURLMOPT_MAXCONNECTS (3),
  48. .BR CURLMOPT_MAX_HOST_CONNECTIONS (3),
  49. .BR CURLMOPT_MAX_TOTAL_CONNECTIONS (3),
  50. .BR CURLOPT_MAXREDIRS (3)