libcurl-multi.3: mention curl_multi_wait

... and some general rewordings to improve this docs.

Reported-by: Tim Stack

Closes #356
This commit is contained in:
Daniel Stenberg
2015-07-30 10:17:37 +02:00
parent bdd8cf4777
commit fc69e2f7ec

View File

@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@@ -51,28 +51,27 @@ To use the multi interface, you must first create a 'multi handle' with
\fIcurl_multi_init(3)\fP. This handle is then used as input to all further \fIcurl_multi_init(3)\fP. This handle is then used as input to all further
curl_multi_* functions. curl_multi_* functions.
With a multi handle and the multi interface you can do any amount of With a multi handle and the multi interface you can do several simultaneous
simultaneous transfers in parallel. Each single transfer is built up around an transfers in parallel. Each single transfer is built up around an easy
easy handle. You must create the easy handles you need, and setup the handle. You create all the easy handles you need, and setup the appropriate
appropriate options for each easy handle, as outlined in the \fIlibcurl(3)\fP options for each easy handle using \fIcurl_easy_setopt(3)\fP.
man page, using \fIcurl_easy_setopt(3)\fP.
There are two flavours of the multi interface, the select() oriented one and There are two flavours of the multi interface, the select() oriented one and
the event based one we called multi_socket. You will benefit from reading the event based one we call multi_socket. You will benefit from reading
through the description of both versions to full understand how they work and through the description of both versions to fully understand how they work and
differentiate. We start out with the select() oriented version. differentiate. We start out with the select() oriented version.
When an easy handle is setup for a transfer, then instead of using When an easy handle is setup and ready for transfer, then instead of using
\fIcurl_easy_perform(3)\fP like when using the easy interface for transfers, \fIcurl_easy_perform(3)\fP like when using the easy interface for transfers,
you should add the easy handle to the multi handle with you should add the easy handle to the multi handle with
\fIcurl_multi_add_handle(3)\fP. The multi handle is sometimes referred to as a \fIcurl_multi_add_handle(3)\fP. You can add more easy handles to a multi
\'multi stack\' because of the fact that it may hold a large amount of easy handle at any point, even if other transfers are already running.
handles.
Should you change your mind, the easy handle is again removed from the multi Should you change your mind, the easy handle is again removed from the multi
stack using \fIcurl_multi_remove_handle(3)\fP. Once removed from the multi stack using \fIcurl_multi_remove_handle(3)\fP. Once removed from the multi
handle, you can again use other easy interface functions like handle, you can again use other easy interface functions like
\fIcurl_easy_perform(3)\fP on the handle or whatever you think is necessary. \fIcurl_easy_perform(3)\fP on the handle or whatever you think is
necessary. You can remove handles at any point in time during transfers.
Adding the easy handle to the multi handle does not start the transfer. Adding the easy handle to the multi handle does not start the transfer.
Remember that one of the main ideas with this interface is to let your Remember that one of the main ideas with this interface is to let your
@@ -84,16 +83,16 @@ current transfers in the multi stack that are ready to transfer anything. It
may be all, it may be none. When there's nothing more to do for now, it may be all, it may be none. When there's nothing more to do for now, it
returns back to the calling application. returns back to the calling application.
Your application can acquire knowledge from libcurl when it would like to get Your application extracts info from libcurl about when it would like to get
invoked to transfer data, so that you don't have to busy-loop and call that invoked to transfer data or do other work. The most convenient way is to use
\fIcurl_multi_perform(3)\fP like crazy. \fIcurl_multi_fdset(3)\fP offers an \fIcurl_multi_wait(3)\fP that will help you wait until the application should
interface using which you can extract fd_sets from libcurl to use in select() call libcurl again. The older API to accomplish the same thing is
or poll() calls in order to get to know when the transfers in the multi stack \fIcurl_multi_fdset(3)\fP that extracts fd_sets from libcurl to use in
might need attention. This also makes it very easy for your program to wait select() or poll() calls in order to get to know when the transfers in the
for input on your own private file descriptors at the same time or perhaps multi stack might need attention. Both these APIs allow for your program to
timeout every now and then, should you want that. \fIcurl_multi_timeout(3)\fP wait for input on your own private file descriptors at the same time
also helps you with providing a suitable timeout period for your select() \fIcurl_multi_timeout(3)\fP also helps you with providing a suitable timeout
call. period for your select() calls.
\fIcurl_multi_perform(3)\fP stores the number of still running transfers in \fIcurl_multi_perform(3)\fP stores the number of still running transfers in
one of its input arguments, and by reading that you can figure out when all one of its input arguments, and by reading that you can figure out when all
@@ -114,9 +113,9 @@ the multi stack. You need to first remove the easy handle with
\fIcurl_easy_cleanup(3)\fP, or possibly set new options to it and add it again \fIcurl_easy_cleanup(3)\fP, or possibly set new options to it and add it again
with \fIcurl_multi_add_handle(3)\fP to start another transfer. with \fIcurl_multi_add_handle(3)\fP to start another transfer.
When all transfers in the multi stack are done, cleanup the multi handle with When all transfers in the multi stack are done, close the multi handle with
\fIcurl_multi_cleanup(3)\fP. Be careful and please note that you \fBMUST\fP \fIcurl_multi_cleanup(3)\fP. Be careful and please note that you \fBMUST\fP
invoke separate \fIcurl_easy_cleanup(3)\fP calls on every single easy handle invoke separate \fIcurl_easy_cleanup(3)\fP calls for every single easy handle
to clean them up properly. to clean them up properly.
If you want to re-use an easy handle that was added to the multi handle for If you want to re-use an easy handle that was added to the multi handle for