curl_multi_info_read.3 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. .\" generated by cd2nroff 0.1 from curl_multi_info_read.md
  2. .TH curl_multi_info_read 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_multi_info_read \- read multi stack information
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMsg *curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue);
  9. .fi
  10. .SH DESCRIPTION
  11. Ask the multi handle if there are any messages from the individual
  12. transfers. Messages may include information such as an error code from the
  13. transfer or just the fact that a transfer is completed. More details on these
  14. should be written down as well.
  15. Repeated calls to this function returns a new struct each time, until a NULL
  16. is returned as a signal that there is no more to get at this point. The
  17. integer pointed to with \fImsgs_in_queue\fP contains the number of remaining
  18. messages after this function was called.
  19. When you fetch a message using this function, it is removed from the internal
  20. queue so calling this function again does not return the same message
  21. again. It instead returns new messages at each new invoke until the queue is
  22. emptied.
  23. \fBWARNING:\fP The data the returned pointer points to does not survive
  24. calling \fIcurl_multi_cleanup(3)\fP, \fIcurl_multi_remove_handle(3)\fP or
  25. \fIcurl_easy_cleanup(3)\fP.
  26. The \fICURLMsg\fP struct is simple and only contains basic information. If
  27. more involved information is wanted, the particular "easy handle" is present
  28. in that struct and can be used in subsequent regular
  29. \fIcurl_easy_getinfo(3)\fP calls (or similar):
  30. .nf
  31. struct CURLMsg {
  32. CURLMSG msg; /* what this message means */
  33. CURL *easy_handle; /* the handle it concerns */
  34. union {
  35. void *whatever; /* message-specific data */
  36. CURLcode result; /* return code for transfer */
  37. } data;
  38. };
  39. .fi
  40. When \fBmsg\fP is \fICURLMSG_DONE\fP, the message identifies a transfer that
  41. is done, and then \fBresult\fP contains the return code for the easy handle
  42. that just completed.
  43. At this point, there are no other \fBmsg\fP types defined.
  44. .SH PROTOCOLS
  45. This functionality affects all supported protocols
  46. .SH EXAMPLE
  47. .nf
  48. int main(void)
  49. {
  50. CURLM *multi = curl_multi_init();
  51. CURL *curl = curl_easy_init();
  52. if(curl) {
  53. struct CURLMsg *m;
  54. /* call curl_multi_perform or curl_multi_socket_action first, then loop
  55. through and check if there are any transfers that have completed */
  56. do {
  57. int msgq = 0;
  58. m = curl_multi_info_read(multi, &msgq);
  59. if(m && (m->msg == CURLMSG_DONE)) {
  60. CURL *e = m->easy_handle;
  61. /* m->data.result holds the error code for the transfer */
  62. curl_multi_remove_handle(multi, e);
  63. curl_easy_cleanup(e);
  64. }
  65. } while(m);
  66. }
  67. }
  68. .fi
  69. .SH AVAILABILITY
  70. Added in curl 7.9.6
  71. .SH RETURN VALUE
  72. A pointer to a filled\-in struct, or NULL if it failed or ran out of
  73. structs. It also writes the number of messages left in the queue (after this
  74. read) in the integer the second argument points to.
  75. .SH SEE ALSO
  76. .BR curl_multi_cleanup (3),
  77. .BR curl_multi_init (3),
  78. .BR curl_multi_perform (3)