CURLOPT_PORT.3 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .\" generated by cd2nroff 0.1 from CURLOPT_PORT.md
  2. .TH CURLOPT_PORT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_PORT \- remote port number to connect to
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PORT, long number);
  9. .fi
  10. .SH DESCRIPTION
  11. We discourage using this option since its scope is not obvious and hard to
  12. predict. Set the preferred port number in the URL instead.
  13. This option sets \fInumber\fP to be the remote port number to connect to,
  14. instead of the one specified in the URL or the default port for the used
  15. protocol.
  16. Usually, you just let the URL decide which port to use but this allows the
  17. application to override that.
  18. While this option accepts a \(aqlong\(aq, a port number is an unsigned 16 bit number
  19. and therefore using a port number lower than zero or over 65535 causes a
  20. \fBCURLE_BAD_FUNCTION_ARGUMENT\fP error.
  21. .SH DEFAULT
  22. 0 which makes it not used. This also makes port number zero impossible to set
  23. with this API.
  24. .SH PROTOCOLS
  25. This functionality affects all supported protocols
  26. .SH EXAMPLE
  27. .nf
  28. int main(void)
  29. {
  30. CURL *curl = curl_easy_init();
  31. if(curl) {
  32. CURLcode res;
  33. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  34. curl_easy_setopt(curl, CURLOPT_PORT, 8080L);
  35. res = curl_easy_perform(curl);
  36. curl_easy_cleanup(curl);
  37. }
  38. }
  39. .fi
  40. .SH AVAILABILITY
  41. Added in curl 7.1
  42. .SH RETURN VALUE
  43. Returns CURLE_OK
  44. .SH SEE ALSO
  45. .BR CURLINFO_PRIMARY_PORT (3),
  46. .BR CURLOPT_STDERR (3),
  47. .BR CURLOPT_URL (3)