curl_multi_timeout.3 3.3 KB

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