1curl_multi_perform(3)           libcurl Manual           curl_multi_perform(3)
2
3
4

NAME

6       curl_multi_perform - reads/writes available data from easy handles
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);
12

DESCRIPTION

14       This function performs transfers on all the added handles that need at‐
15       tention in a non-blocking fashion. The  easy  handles  have  previously
16       been added to the multi handle with curl_multi_add_handle(3).
17
18       When  an  application  has  found  out  there's  data available for the
19       multi_handle or a timeout has elapsed, the application should call this
20       function  to  read/write  whatever  there is to read or write right now
21       etc.  curl_multi_perform(3) returns as soon  as  the  reads/writes  are
22       done.  This  function  does not require that there actually is any data
23       available for reading or that data can be written,  it  can  be  called
24       just  in  case. It will store the number of handles that still transfer
25       data in the second argument's integer-pointer.
26
27       If the amount of running_handles is changed from the previous call  (or
28       is  less  than  the  amount of easy handles you have added to the multi
29       handle), you know that there is one or more transfers  less  "running".
30       You can then call curl_multi_info_read(3) to get information about each
31       individual completed transfer, and that returned info includes CURLcode
32       and  more. If an added handle fails quickly, it may never be counted as
33       a running_handle. You could use curl_multi_info_read(3) to track actual
34       status of the added handles in that case.
35
36       When running_handles is set to zero (0) on the return of this function,
37       there is no longer any transfers in progress.
38
39       When this function returns error, the state of all transfers are uncer‐
40       tain  and they cannot be continued. curl_multi_perform(3) should not be
41       called again on the same multi handle after an error has been returned,
42       unless first removing all the handles and adding new ones.
43

EXAMPLE

45       int still_running;
46       do {
47         CURLMcode mc = curl_multi_perform(multi_handle, &still_running);
48
49         if(!mc && still_running)
50           /* wait for activity, timeout or "nothing" */
51           mc = curl_multi_poll(multi_handle, NULL, 0, 1000, NULL);
52
53         if(mc) {
54           fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mc);
55           break;
56         }
57
58       /* if there are still transfers, loop! */
59       } while(still_running);
60

AVAILABILITY

62       Added in 7.9.6
63

RETURN VALUE

65       CURLMcode type, general libcurl multi interface error code.
66
67       This  function returns errors regarding the whole multi stack. Problems
68       on individual transfers may have occurred even when this  function  re‐
69       turns  CURLM_OK. Use curl_multi_info_read(3) to figure out how individ‐
70       ual transfers did.
71

TYPICAL USAGE

73       Most applications will use curl_multi_poll(3) to make libcurl wait  for
74       activity  on  any of the ongoing transfers. As soon as one or more file
75       descriptor has activity or the  function  times  out,  the  application
76       calls curl_multi_perform(3).
77

SEE ALSO

79       curl_multi_cleanup(3),      curl_multi_init(3),     curl_multi_wait(3),
80       curl_multi_add_handle(3), curl_multi_fdset(3), curl_multi_info_read(3),
81       libcurl-errors(3)
82
83
84
85libcurl 7.85.0                  August 15, 2022          curl_multi_perform(3)
Impressum