CURLOPT_CONNECTTIMEOUT.3 2.3 KB

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