curl_multi_info_read.3 3.8 KB

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