1curl_multi_info_read(3)             libcurl            curl_multi_info_read(3)
2
3
4

NAME

6       curl_multi_info_read - read multi stack information
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLMsg *curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue);
12

DESCRIPTION

14       Ask  the  multi  handle  if  there are any messages from the individual
15       transfers. Messages may include information such as an error code  from
16       the  transfer  or  just the fact that a transfer is completed. More de‐
17       tails on these should be written down as well.
18
19       Repeated calls to this function will return a new struct each time, un‐
20       til a NULL is returned as a signal that there is no more to get at this
21       point. The integer pointed to with msgs_in_queue will contain the  num‐
22       ber of remaining messages after this function was called.
23
24       When  you  fetch  a message using this function, it is removed from the
25       internal queue so calling this function again will not return the  same
26       message  again.  It will instead return new messages at each new invoke
27       until the queue is emptied.
28
29       WARNING: The data the returned pointer points to will not survive call‐
30       ing      curl_multi_cleanup(3),      curl_multi_remove_handle(3)     or
31       curl_easy_cleanup(3).
32
33       The CURLMsg struct is simple and only contains  basic  information.  If
34       more  involved  information  is wanted, the particular "easy handle" is
35       present  in  that  struct  and  can  be  used  in  subsequent   regular
36       curl_easy_getinfo(3) calls (or similar):
37
38        struct CURLMsg {
39          CURLMSG msg;       /* what this message means */
40          CURL *easy_handle; /* the handle it concerns */
41          union {
42            void *whatever;    /* message-specific data */
43            CURLcode result;   /* return code for transfer */
44          } data;
45        };
46       When  msg  is  CURLMSG_DONE,  the message identifies a transfer that is
47       done, and then result contains the return code for the easy handle that
48       just completed.
49
50       At this point, there are no other msg types defined.
51

EXAMPLE

53       struct CURLMsg *m;
54
55       /* call curl_multi_perform or curl_multi_socket_action first, then loop
56          through and check if there are any transfers that have completed */
57
58       do {
59         int msgq = 0;
60         m = curl_multi_info_read(multi_handle, &msgq);
61         if(m && (m->msg == CURLMSG_DONE)) {
62           CURL *e = m->easy_handle;
63           transfers--;
64           curl_multi_remove_handle(multi_handle, e);
65           curl_easy_cleanup(e);
66         }
67       } while(m);
68

AVAILABILITY

70       Added in 7.9.6
71

RETURN VALUE

73       A  pointer  to  a  filled-in struct, or NULL if it failed or ran out of
74       structs. It also writes the number of messages left in the queue (after
75       this read) in the integer the second argument points to.
76

SEE ALSO

78       curl_multi_cleanup(3), curl_multi_init(3), curl_multi_perform(3)
79
80
81
82libcurl 8.2.1                   April 26, 2023         curl_multi_info_read(3)
Impressum