CURLOPT_LOCALPORT.3 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. .\" generated by cd2nroff 0.1 from CURLOPT_LOCALPORT.md
  2. .TH CURLOPT_LOCALPORT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_LOCALPORT \- local port number to use for socket
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORT, long port);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. This sets the local port number of the socket used for the
  12. connection. This can be used in combination with \fICURLOPT_INTERFACE(3)\fP
  13. and you are recommended to use \fICURLOPT_LOCALPORTRANGE(3)\fP as well when
  14. this option is set. Valid port numbers are 1 \- 65535.
  15. .SH DEFAULT
  16. 0, disabled \- use whatever the system thinks is fine
  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/foo.bin");
  27. curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
  28. /* and try 20 more ports following that */
  29. curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
  30. res = curl_easy_perform(curl);
  31. curl_easy_cleanup(curl);
  32. }
  33. }
  34. .fi
  35. .SH AVAILABILITY
  36. Added in curl 7.15.2
  37. .SH RETURN VALUE
  38. Returns CURLE_OK
  39. .SH SEE ALSO
  40. .BR CURLINFO_LOCAL_PORT (3),
  41. .BR CURLOPT_INTERFACE (3),
  42. .BR CURLOPT_LOCALPORTRANGE (3)