Imported Upstream version 7.48.0
[platform/upstream/curl.git] / docs / libcurl / curl_multi_info_read.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2015, 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_info_read 3 "18 Dec 2004" "libcurl 7.10.3" "libcurl Manual"
23 .SH NAME
24 curl_multi_info_read - read multi stack informationals
25 .SH SYNOPSIS
26 #include <curl/curl.h>
27
28 CURLMsg *curl_multi_info_read( CURLM *multi_handle,
29                                int *msgs_in_queue);
30 .ad
31 .SH DESCRIPTION
32 Ask the multi handle if there are any messages/informationals from the
33 individual transfers. Messages may include informationals such as an error
34 code from the transfer or just the fact that a transfer is completed. More
35 details on these should be written down as well.
36
37 Repeated calls to this function will return a new struct each time, until a
38 NULL is returned as a signal that there is no more to get at this point. The
39 integer pointed to with \fImsgs_in_queue\fP will contain the number of
40 remaining messages after this function was called.
41
42 When you fetch a message using this function, it is removed from the internal
43 queue so calling this function again will not return the same message
44 again. It will instead return new messages at each new invoke until the queue
45 is emptied.
46
47 \fBWARNING:\fP The data the returned pointer points to will not survive
48 calling \fIcurl_multi_cleanup(3)\fP, \fIcurl_multi_remove_handle(3)\fP or
49 \fIcurl_easy_cleanup(3)\fP.
50
51 The 'CURLMsg' struct is very simple and only contains very basic information.
52 If more involved information is wanted, the particular "easy handle" is
53 present in that struct and can be used in subsequent regular
54 \fIcurl_easy_getinfo(3)\fP calls (or similar):
55
56 .nf
57  struct CURLMsg {
58    CURLMSG msg;       /* what this message means */
59    CURL *easy_handle; /* the handle it concerns */
60    union {
61      void *whatever;    /* message-specific data */
62      CURLcode result;   /* return code for transfer */
63    } data;
64  };
65 .fi
66 When \fBmsg\fP is \fICURLMSG_DONE\fP, the message identifies a transfer that
67 is done, and then \fBresult\fP contains the return code for the easy handle
68 that just completed.
69
70 At this point, there are no other \fBmsg\fP types defined.
71 .SH EXAMPLE
72 .nf
73 struct CURLMsg *m;
74
75 /* call curl_multi_perform or curl_multi_socket_action first, then loop
76    through and check if there are any transfers that have completed */
77
78 do {
79   int msgq = 0;
80   m = curl_multi_info_read(multi_handle, &msgq);
81   if(m && (m->msg == CURLMSG_DONE)) {
82     CURL *e = m->easy_handle;
83     transfers--;
84     curl_multi_remove_handle(multi_handle, e);
85     curl_easy_cleanup(e);
86   }
87 } while(m);
88 .fi
89 .SH "RETURN VALUE"
90 A pointer to a filled-in struct, or NULL if it failed or ran out of
91 structs. It also writes the number of messages left in the queue (after this
92 read) in the integer the second argument points to.
93 .SH "SEE ALSO"
94 .BR curl_multi_cleanup "(3), " curl_multi_init "(3), " curl_multi_perform "(3)"