curl_multi_perform.3 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_perform 3 "1 March 2002" "libcurl 7.9.5" "libcurl Manual"
  25. .SH NAME
  26. curl_multi_perform - reads/writes available data from easy handles
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);
  31. .fi
  32. .SH DESCRIPTION
  33. This function performs transfers on all the added handles that need attention
  34. in a non-blocking fashion. The easy handles have previously been added to the
  35. multi handle with \fIcurl_multi_add_handle(3)\fP.
  36. When an application has found out there's data available for the multi_handle
  37. or a timeout has elapsed, the application should call this function to
  38. read/write whatever there is to read or write right now etc.
  39. \fIcurl_multi_perform(3)\fP returns as soon as the reads/writes are done. This
  40. function does not require that there actually is any data available for
  41. reading or that data can be written, it can be called just in case. It will
  42. store the number of handles that still transfer data in the second argument's
  43. integer-pointer.
  44. If the amount of \fIrunning_handles\fP is changed from the previous call (or
  45. is less than the amount of easy handles you have added to the multi handle),
  46. you know that there is one or more transfers less "running". You can then call
  47. \fIcurl_multi_info_read(3)\fP to get information about each individual
  48. completed transfer, and that returned info includes CURLcode and more. If an
  49. added handle fails quickly, it may never be counted as a running_handle. You
  50. could use \fIcurl_multi_info_read(3)\fP to track actual status of the added
  51. handles in that case.
  52. When \fIrunning_handles\fP is set to zero (0) on the return of this function,
  53. there is no longer any transfers in progress.
  54. When this function returns error, the state of all transfers are uncertain and
  55. they cannot be continued. \fIcurl_multi_perform(3)\fP should not be called
  56. again on the same multi handle after an error has been returned, unless first
  57. removing all the handles and adding new ones.
  58. .SH EXAMPLE
  59. .nf
  60. int still_running;
  61. do {
  62. CURLMcode mc = curl_multi_perform(multi_handle, &still_running);
  63. if(!mc && still_running)
  64. /* wait for activity, timeout or "nothing" */
  65. mc = curl_multi_poll(multi_handle, NULL, 0, 1000, NULL);
  66. if(mc) {
  67. fprintf(stderr, "curl_multi_poll() failed, code %d.\\n", (int)mc);
  68. break;
  69. }
  70. /* if there are still transfers, loop! */
  71. } while(still_running);
  72. .fi
  73. .SH AVAILABILITY
  74. Added in 7.9.6
  75. .SH RETURN VALUE
  76. CURLMcode type, general libcurl multi interface error code.
  77. This function returns errors regarding the whole multi stack. Problems on
  78. individual transfers may have occurred even when this function returns
  79. \fICURLM_OK\fP. Use \fIcurl_multi_info_read(3)\fP to figure out how individual
  80. transfers did.
  81. .SH "TYPICAL USAGE"
  82. Most applications will use \fIcurl_multi_poll(3)\fP to make libcurl wait for
  83. activity on any of the ongoing transfers. As soon as one or more file
  84. descriptor has activity or the function times out, the application calls
  85. \fIcurl_multi_perform(3)\fP.
  86. .SH "SEE ALSO"
  87. .BR curl_multi_cleanup "(3), " curl_multi_init "(3), "
  88. .BR curl_multi_wait "(3), " curl_multi_add_handle "(3), "
  89. .BR curl_multi_fdset "(3), " curl_multi_info_read "(3), "
  90. .BR libcurl-errors "(3)"