CURLOPT_CONNECTTIMEOUT_MS.3 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .\" generated by cd2nroff 0.1 from CURLOPT_CONNECTTIMEOUT_MS.md
  2. .TH CURLOPT_CONNECTTIMEOUT_MS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_CONNECTTIMEOUT_MS \- timeout for the connect phase
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT_MS,
  9. long timeout);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a long. It sets the maximum time in milliseconds that you allow the
  13. connection phase to take. This timeout only limits the connection phase, it
  14. has no impact once libcurl has connected. The connection phase includes the
  15. name resolve (DNS) and all protocol handshakes and negotiations until there is
  16. an established connection with the remote side.
  17. Set this option to zero to switch to the default built\-in connection timeout \-
  18. 300 seconds. See also the \fICURLOPT_TIMEOUT_MS(3)\fP option.
  19. \fICURLOPT_CONNECTTIMEOUT(3)\fP is the same function but set in seconds.
  20. If both \fICURLOPT_CONNECTTIMEOUT(3)\fP and \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP are set,
  21. the value set last is used.
  22. The connection timeout is included in the general all\-covering
  23. \fICURLOPT_TIMEOUT_MS(3)\fP:
  24. With \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP set to 3000 and \fICURLOPT_TIMEOUT_MS(3)\fP set to
  25. 5000, the operation can never last longer than 5000 milliseconds, and the
  26. connection phase cannot last longer than 3000 milliseconds.
  27. With \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP set to 4000 and \fICURLOPT_TIMEOUT_MS(3)\fP set to
  28. 2000, the operation can never last longer than 2000 milliseconds. Including
  29. the connection phase.
  30. This option may cause libcurl to use the SIGALRM signal to timeout system
  31. calls on builds not using asynch DNS. In unix\-like systems, this might cause
  32. signals to be used unless \fICURLOPT_NOSIGNAL(3)\fP is set.
  33. .SH DEFAULT
  34. 300000
  35. .SH PROTOCOLS
  36. This functionality affects all supported protocols
  37. .SH EXAMPLE
  38. .nf
  39. int main(void)
  40. {
  41. CURL *curl = curl_easy_init();
  42. if(curl) {
  43. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  44. /* complete connection within 10000 milliseconds */
  45. curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L);
  46. curl_easy_perform(curl);
  47. }
  48. }
  49. .fi
  50. .SH AVAILABILITY
  51. Added in curl 7.16.2
  52. .SH RETURN VALUE
  53. Returns CURLE_OK
  54. .SH SEE ALSO
  55. .BR CURLOPT_LOW_SPEED_LIMIT (3),
  56. .BR CURLOPT_MAX_RECV_SPEED_LARGE (3),
  57. .BR CURLOPT_TIMEOUT_MS (3)