CURLINFO_NUM_CONNECTS.3 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. .\" generated by cd2nroff 0.1 from CURLINFO_NUM_CONNECTS.md
  2. .TH CURLINFO_NUM_CONNECTS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_NUM_CONNECTS \- get number of created connections
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NUM_CONNECTS, long *nump);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a long to receive how many new connections libcurl had to
  12. create to achieve the previous transfer (only the successful connects are
  13. counted). Combined with \fICURLINFO_REDIRECT_COUNT(3)\fP you are able to know how
  14. many times libcurl successfully reused existing connection(s) or not. See the
  15. connection options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries to make
  16. persistent connections to save time.
  17. .SH PROTOCOLS
  18. This functionality affects all supported protocols
  19. .SH EXAMPLE
  20. .nf
  21. int main(void)
  22. {
  23. CURL *curl = curl_easy_init();
  24. if(curl) {
  25. CURLcode res;
  26. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  27. curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  28. res = curl_easy_perform(curl);
  29. if(res == CURLE_OK) {
  30. long connects;
  31. res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
  32. if(!res)
  33. printf("It needed %ld connects\\n", connects);
  34. }
  35. curl_easy_cleanup(curl);
  36. }
  37. }
  38. .fi
  39. .SH AVAILABILITY
  40. Added in curl 7.12.3
  41. .SH RETURN VALUE
  42. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  43. .SH SEE ALSO
  44. .BR curl_easy_getinfo (3),
  45. .BR curl_easy_setopt (3)