1curl_multi_info_read(3) libcurl Manual curl_multi_info_read(3)
2
3
4
6 curl_multi_info_read - read multi stack informationals
7
9 #include <curl/curl.h>
10
11 CURLMsg *curl_multi_info_read( CURLM *multi_handle,
12 int *msgs_in_queue);
13
15 Ask the multi handle if there are any messages/informationals from the
16 individual transfers. Messages may include informationals such as an
17 error code from the transfer or just the fact that a transfer is com‐
18 pleted. More details on these should be written down as well.
19
20 Repeated calls to this function will return a new struct each time, un‐
21 til a NULL is returned as a signal that there is no more to get at this
22 point. The integer pointed to with msgs_in_queue will contain the num‐
23 ber of remaining messages after this function was called.
24
25 When you fetch a message using this function, it is removed from the
26 internal queue so calling this function again will not return the same
27 message again. It will instead return new messages at each new invoke
28 until the queue is emptied.
29
30 WARNING: The data the returned pointer points to will not survive call‐
31 ing curl_multi_cleanup(3), curl_multi_remove_handle(3) or
32 curl_easy_cleanup(3).
33
34 The 'CURLMsg' struct is very simple and only contains very basic infor‐
35 mation. If more involved information is wanted, the particular "easy
36 handle" is present in that struct and can be used in subsequent regular
37 curl_easy_getinfo(3) calls (or similar):
38
39 struct CURLMsg {
40 CURLMSG msg; /* what this message means */
41 CURL *easy_handle; /* the handle it concerns */
42 union {
43 void *whatever; /* message-specific data */
44 CURLcode result; /* return code for transfer */
45 } data;
46 };
47 When msg is CURLMSG_DONE, the message identifies a transfer that is
48 done, and then result contains the return code for the easy handle that
49 just completed.
50
51 At this point, there are no other msg types defined.
52
54 struct CURLMsg *m;
55
56 /* call curl_multi_perform or curl_multi_socket_action first, then loop
57 through and check if there are any transfers that have completed */
58
59 do {
60 int msgq = 0;
61 m = curl_multi_info_read(multi_handle, &msgq);
62 if(m && (m->msg == CURLMSG_DONE)) {
63 CURL *e = m->easy_handle;
64 transfers--;
65 curl_multi_remove_handle(multi_handle, e);
66 curl_easy_cleanup(e);
67 }
68 } while(m);
69
71 A pointer to a filled-in struct, or NULL if it failed or ran out of
72 structs. It also writes the number of messages left in the queue (after
73 this read) in the integer the second argument points to.
74
76 curl_multi_cleanup(3), curl_multi_init(3), curl_multi_perform(3)
77
78
79
80libcurl 7.76.1 November 04, 2020 curl_multi_info_read(3)