curl_multi_timeout.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2016, 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. .TH curl_multi_timeout 3 "2 Jan 2006" "libcurl 7.16.0" "libcurl Manual"
  23. .SH NAME
  24. curl_multi_timeout \- how long to wait for action before proceeding
  25. .SH SYNOPSIS
  26. #include <curl/curl.h>
  27. CURLMcode curl_multi_timeout(CURLM *multi_handle, long *timeout);
  28. .SH DESCRIPTION
  29. An application using the libcurl multi interface should call
  30. \fIcurl_multi_timeout(3)\fP to figure out how long it should wait for socket
  31. actions \- at most \- before proceeding.
  32. Proceeding means either doing the socket-style timeout action: call the
  33. \fIcurl_multi_socket_action(3)\fP function with the \fBsockfd\fP argument set
  34. to CURL_SOCKET_TIMEOUT, or call \fIcurl_multi_perform(3)\fP if you're using
  35. the simpler and older multi interface approach.
  36. The timeout value returned in the long \fBtimeout\fP points to, is in number
  37. of milliseconds at this very moment. If 0, it means you should proceed
  38. immediately without waiting for anything. If it returns -1, there's no timeout
  39. at all set.
  40. An application that uses the multi_socket API SHOULD NOT use this function, but
  41. SHOULD instead use \fIcurl_multi_setopt(3)\fP and its
  42. \fPCURLMOPT_TIMERFUNCTION\fP option for proper and desired behavior.
  43. Note: if libcurl returns a -1 timeout here, it just means that libcurl
  44. currently has no stored timeout value. You must not wait too long (more than a
  45. few seconds perhaps) before you call curl_multi_perform() again.
  46. .SH EXAMPLE
  47. .nf
  48. struct timeval timeout;
  49. long timeo;
  50. curl_multi_timeout(multi_handle, &timeo);
  51. if(timeo < 0)
  52. /* no set timeout, use a default */
  53. timeo = 980;
  54. timeout.tv_sec = timeo / 1000;
  55. timeout.tv_usec = (timeo % 1000) * 1000;
  56. /* wait for activities no longer than the set timeout */
  57. select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
  58. .fi
  59. .SH "RETURN VALUE"
  60. The standard CURLMcode for multi interface error codes.
  61. .SH "TYPICAL USAGE"
  62. Call \fIcurl_multi_timeout(3)\fP, then wait for action on the sockets. You
  63. figure out which sockets to wait for by calling \fIcurl_multi_fdset(3)\fP or
  64. by a previous call to \fIcurl_multi_socket(3)\fP.
  65. .SH AVAILABILITY
  66. This function was added in libcurl 7.15.4.
  67. .SH "SEE ALSO"
  68. .BR curl_multi_fdset "(3), " curl_multi_info_read "(3), "
  69. .BR curl_multi_socket "(3), " curl_multi_setopt "(3) "