CURLINFO_LOCAL_PORT.3 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. .\" generated by cd2nroff 0.1 from CURLINFO_LOCAL_PORT.md
  2. .TH CURLINFO_LOCAL_PORT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_LOCAL_PORT \- get the latest local port number
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_PORT, long *portp);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a long to receive the local port number of the most recent
  12. connection done with this \fBcurl\fP handle.
  13. .SH PROTOCOLS
  14. This functionality affects tcp only
  15. .SH EXAMPLE
  16. .nf
  17. int main(void)
  18. {
  19. CURL *curl;
  20. CURLcode res;
  21. curl = curl_easy_init();
  22. if(curl) {
  23. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  24. res = curl_easy_perform(curl);
  25. if(CURLE_OK == res) {
  26. long port;
  27. res = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
  28. if(CURLE_OK == res) {
  29. printf("We used local port: %ld\\n", port);
  30. }
  31. }
  32. curl_easy_cleanup(curl);
  33. }
  34. return 0;
  35. }
  36. .fi
  37. .SH AVAILABILITY
  38. Added in curl 7.21.0
  39. .SH RETURN VALUE
  40. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  41. .SH SEE ALSO
  42. .BR CURLINFO_LOCAL_IP (3),
  43. .BR CURLINFO_PRIMARY_PORT (3),
  44. .BR curl_easy_getinfo (3),
  45. .BR curl_easy_setopt (3)