curl_multi_info_read.3 3.8 KB

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