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