CURLINFO_OS_ERRNO.3 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .\" generated by cd2nroff 0.1 from CURLINFO_OS_ERRNO.md
  2. .TH CURLINFO_OS_ERRNO 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_OS_ERRNO \- get errno number from last connect failure
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a long to receive the errno variable from a connect failure.
  12. Note that the value is only set on failure, it is not reset upon a successful
  13. operation. The number is OS and system specific.
  14. libcurl network\-related errors that may have a saved errno are:
  15. CURLE_COULDNT_CONNECT, CURLE_FAILED_INIT, CURLE_INTERFACE_FAILED,
  16. CURLE_OPERATION_TIMEDOUT, CURLE_RECV_ERROR, CURLE_SEND_ERROR.
  17. Since 8.8.0 libcurl clears the easy handle\(aqs saved errno before performing the
  18. transfer. Prior versions did not clear the saved errno, which means if a saved
  19. errno is retrieved it could be from a previous transfer on the same handle.
  20. .SH PROTOCOLS
  21. This functionality affects all supported protocols
  22. .SH EXAMPLE
  23. .nf
  24. int main(void)
  25. {
  26. CURL *curl = curl_easy_init();
  27. if(curl) {
  28. CURLcode res;
  29. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  30. res = curl_easy_perform(curl);
  31. if(res != CURLE_OK) {
  32. long error;
  33. res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
  34. if(!res && error) {
  35. printf("Errno: %ld\\n", error);
  36. }
  37. }
  38. curl_easy_cleanup(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.12.2
  44. .SH RETURN VALUE
  45. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  46. .SH SEE ALSO
  47. .BR curl_easy_getinfo (3),
  48. .BR curl_easy_setopt (3)