2011-03-12 07:14:32 +08:00
|
|
|
.\" **************************************************************************
|
|
|
|
.\" * _ _ ____ _
|
|
|
|
.\" * Project ___| | | | _ \| |
|
|
|
|
.\" * / __| | | | |_) | |
|
|
|
|
.\" * | (__| |_| | _ <| |___
|
|
|
|
.\" * \___|\___/|_| \_\_____|
|
|
|
|
.\" *
|
2021-10-20 14:49:17 +08:00
|
|
|
.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2011-03-12 07:14:32 +08:00
|
|
|
.\" *
|
|
|
|
.\" * This software is licensed as described in the file COPYING, which
|
|
|
|
.\" * you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
.\" * are also available at https://curl.se/docs/copyright.html.
|
2011-03-12 07:14:32 +08:00
|
|
|
.\" *
|
|
|
|
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
.\" * copies of the Software, and permit persons to whom the Software is
|
|
|
|
.\" * furnished to do so, under the terms of the COPYING file.
|
|
|
|
.\" *
|
|
|
|
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
.\" * KIND, either express or implied.
|
|
|
|
.\" *
|
|
|
|
.\" **************************************************************************
|
2002-03-04 18:09:48 +08:00
|
|
|
.TH curl_multi_perform 3 "1 March 2002" "libcurl 7.9.5" "libcurl Manual"
|
|
|
|
.SH NAME
|
2002-10-15 16:39:30 +08:00
|
|
|
curl_multi_perform - reads/writes available data from each easy handle
|
2002-03-04 18:09:48 +08:00
|
|
|
.SH SYNOPSIS
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);
|
|
|
|
.ad
|
|
|
|
.SH DESCRIPTION
|
2021-10-20 14:49:17 +08:00
|
|
|
This function performs transfers on all the added handles that need attention
|
|
|
|
in an non-blocking fashion. The easy handles have previously been added to the
|
|
|
|
multi handle with \fIcurl_multi_add_handle(3)\fP.
|
2012-08-27 06:16:03 +08:00
|
|
|
|
|
|
|
When an application has found out there's data available for the multi_handle
|
|
|
|
or a timeout has elapsed, the application should call this function to
|
|
|
|
read/write whatever there is to read or write right now etc.
|
2014-10-21 16:26:40 +08:00
|
|
|
\fIcurl_multi_perform(3)\fP returns as soon as the reads/writes are done. This
|
2002-03-04 18:09:48 +08:00
|
|
|
function does not require that there actually is any data available for
|
|
|
|
reading or that data can be written, it can be called just in case. It will
|
2021-10-20 14:49:17 +08:00
|
|
|
store the number of handles that still transfer data in the second argument's
|
2002-03-04 18:09:48 +08:00
|
|
|
integer-pointer.
|
2004-10-04 01:38:57 +08:00
|
|
|
|
2012-08-27 06:16:03 +08:00
|
|
|
If the amount of \fIrunning_handles\fP is changed from the previous call (or
|
|
|
|
is less than the amount of easy handles you've added to the multi handle), you
|
|
|
|
know that there is one or more transfers less "running". You can then call
|
|
|
|
\fIcurl_multi_info_read(3)\fP to get information about each individual
|
|
|
|
completed transfer, and that returned info includes CURLcode and more. If an
|
|
|
|
added handle fails very quickly, it may never be counted as a running_handle.
|
2019-10-01 15:55:08 +08:00
|
|
|
You could use \fIcurl_multi_info_read(3)\fP to track actual status of the
|
|
|
|
added handles in that case.
|
2009-09-02 22:57:05 +08:00
|
|
|
|
|
|
|
When \fIrunning_handles\fP is set to zero (0) on the return of this function,
|
|
|
|
there is no longer any transfers in progress.
|
2015-06-02 18:13:23 +08:00
|
|
|
.SH EXAMPLE
|
|
|
|
.nf
|
2021-10-20 14:49:17 +08:00
|
|
|
int still_running;
|
|
|
|
do {
|
|
|
|
CURLMcode mc = curl_multi_perform(multi_handle, &still_running);
|
2015-06-02 18:13:23 +08:00
|
|
|
|
2021-10-20 14:49:17 +08:00
|
|
|
if(!mc && still_running)
|
|
|
|
/* wait for activity, timeout or "nothing" */
|
|
|
|
mc = curl_multi_poll(multi_handle, NULL, 0, 1000, NULL);
|
2015-06-02 18:13:23 +08:00
|
|
|
|
2021-10-20 14:49:17 +08:00
|
|
|
if(mc) {
|
|
|
|
fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mc);
|
|
|
|
break;
|
|
|
|
}
|
2015-06-02 18:13:23 +08:00
|
|
|
|
|
|
|
/* if there are still transfers, loop! */
|
2021-10-20 14:49:17 +08:00
|
|
|
} while(still_running);
|
2015-06-02 18:13:23 +08:00
|
|
|
.fi
|
2002-03-04 18:09:48 +08:00
|
|
|
.SH "RETURN VALUE"
|
|
|
|
CURLMcode type, general libcurl multi interface error code.
|
|
|
|
|
2021-10-20 14:49:17 +08:00
|
|
|
This function returns errors regarding the whole multi stack. Problems on
|
|
|
|
individual transfers may have occurred even when this function returns
|
|
|
|
\fICURLM_OK\fP. Use \fIcurl_multi_info_read(3)\fP to figure out how individual
|
|
|
|
transfers did.
|
2002-03-04 18:09:48 +08:00
|
|
|
.SH "TYPICAL USAGE"
|
2021-10-20 14:49:17 +08:00
|
|
|
Most applications will use \fIcurl_multi_poll(3)\fP to make libcurl wait for
|
|
|
|
activity on any of the ongoing transfers. As soon as one or more file
|
|
|
|
descriptor has activity or the function times out, the application calls
|
|
|
|
\fIcurl_multi_perform(3)\fP.
|
2002-03-04 18:09:48 +08:00
|
|
|
.SH "SEE ALSO"
|
2004-10-04 01:38:57 +08:00
|
|
|
.BR curl_multi_cleanup "(3), " curl_multi_init "(3), "
|
2021-10-20 14:49:17 +08:00
|
|
|
.BR curl_multi_wait "(3), " curl_multi_add_handle "(3), "
|
2006-09-21 19:09:54 +08:00
|
|
|
.BR curl_multi_fdset "(3), " curl_multi_info_read "(3), "
|
|
|
|
.BR libcurl-errors "(3)"
|