CURLOPT_TIMEOUT.3 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.haxx.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_TIMEOUT 3 "October 03, 2017" "libcurl 7.61.1" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_TIMEOUT \- set maximum time the request is allowed to take
  26. .SH SYNOPSIS
  27. #include <curl/curl.h>
  28. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT, long timeout);
  29. .SH DESCRIPTION
  30. Pass a long as parameter containing \fItimeout\fP - the maximum time in
  31. seconds that you allow the libcurl transfer operation to take. Normally, name
  32. lookups can take a considerable time and limiting operations to less than a
  33. few minutes risk aborting perfectly normal operations. This option may cause
  34. libcurl to use the SIGALRM signal to timeout system calls.
  35. In unix-like systems, this might cause signals to be used unless
  36. \fICURLOPT_NOSIGNAL(3)\fP is set.
  37. If both \fICURLOPT_TIMEOUT(3)\fP and \fICURLOPT_TIMEOUT_MS(3)\fP are set, the
  38. value set last will be used.
  39. Since this puts a hard limit for how long time a request is allowed to take,
  40. it has limited use in dynamic use cases with varying transfer times. You are
  41. then advised to explore \fICURLOPT_LOW_SPEED_LIMIT(3)\fP,
  42. \fICURLOPT_LOW_SPEED_TIME(3)\fP or using \fICURLOPT_PROGRESSFUNCTION(3)\fP to
  43. implement your own timeout logic.
  44. .SH DEFAULT
  45. Default timeout is 0 (zero) which means it never times out during transfer.
  46. .SH PROTOCOLS
  47. All
  48. .SH EXAMPLE
  49. .nf
  50. CURL *curl = curl_easy_init();
  51. if(curl) {
  52. curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  53. /* complete within 20 seconds */
  54. curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L);
  55. curl_easy_perform(curl);
  56. }
  57. .fi
  58. .SH AVAILABILITY
  59. Always
  60. .SH RETURN VALUE
  61. Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative
  62. value or a value that when converted to milliseconds is too large.
  63. .SH "SEE ALSO"
  64. .BR CURLOPT_TIMEOUT_MS "(3), "
  65. .BR CURLOPT_CONNECTTIMEOUT "(3), " CURLOPT_LOW_SPEED_LIMIT "(3), "