CURLOPT_LOCALPORTRANGE.3 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. .\" generated by cd2nroff 0.1 from CURLOPT_LOCALPORTRANGE.md
  2. .TH CURLOPT_LOCALPORTRANGE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_LOCALPORTRANGE \- number of additional local ports to try
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORTRANGE,
  9. long range);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a long. The \fIrange\fP argument is the number of attempts libcurl makes
  13. to find a working local port number. It starts with the given
  14. \fICURLOPT_LOCALPORT(3)\fP and adds one to the number for each retry. Setting
  15. this option to 1 or below makes libcurl only do one try for the exact port
  16. number. Port numbers by nature are scarce resources that are busy at times so
  17. setting this value to something too low might cause unnecessary connection
  18. setup failures.
  19. .SH DEFAULT
  20. 1
  21. .SH PROTOCOLS
  22. This functionality affects all supported protocols
  23. .SH EXAMPLE
  24. .nf
  25. int main(void)
  26. {
  27. CURL *curl = curl_easy_init();
  28. if(curl) {
  29. CURLcode res;
  30. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  31. curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
  32. /* and try 20 more ports following that */
  33. curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
  34. res = curl_easy_perform(curl);
  35. curl_easy_cleanup(curl);
  36. }
  37. }
  38. .fi
  39. .SH AVAILABILITY
  40. Added in curl 7.15.2
  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 CURLOPT_INTERFACE (3),
  45. .BR CURLOPT_LOCALPORT (3)