diff options
author | Daniel Stenberg <daniel@haxx.se> | 2009-05-11 20:32:50 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2009-05-11 20:32:50 +0000 |
commit | 8f9d4b2b50da3702a5b3fe1fea2e599746596f16 (patch) | |
tree | 71c796afe9d214f31d8f20d1be8bedac9ad9af92 | |
parent | 78c674a6852a4ef6ccec2b13d2d1f655a8c18549 (diff) |
split off curl_multi_socket_action() into its own separate man page as this is
the function we should use, while both curl_multi_socket() and
curl_multi_socket_all() should be killed!
-rw-r--r-- | docs/libcurl/Makefile.am | 75 | ||||
-rw-r--r-- | docs/libcurl/curl_multi_socket.3 | 23 | ||||
-rw-r--r-- | docs/libcurl/curl_multi_socket_action.3 | 132 |
3 files changed, 173 insertions, 57 deletions
diff --git a/docs/libcurl/Makefile.am b/docs/libcurl/Makefile.am index c2b5f92c5..032f8d344 100644 --- a/docs/libcurl/Makefile.am +++ b/docs/libcurl/Makefile.am @@ -19,44 +19,47 @@ man_MANS = curl_easy_cleanup.3 curl_easy_getinfo.3 curl_easy_init.3 \ libcurl-tutorial.3 curl_easy_reset.3 curl_easy_escape.3 \ curl_easy_unescape.3 curl_multi_setopt.3 curl_multi_socket.3 \ curl_multi_timeout.3 curl_formget.3 curl_multi_assign.3 \ - curl_easy_pause.3 curl_easy_recv.3 curl_easy_send.3 + curl_easy_pause.3 curl_easy_recv.3 curl_easy_send.3 \ + curl_multi_socket_action.3 -HTMLPAGES = curl_easy_cleanup.html curl_easy_getinfo.html \ - curl_easy_init.html curl_easy_perform.html curl_easy_setopt.html \ - curl_easy_duphandle.html curl_formadd.html curl_formfree.html \ - curl_getdate.html curl_getenv.html curl_slist_append.html \ - curl_slist_free_all.html curl_version.html curl_version_info.html \ - curl_escape.html curl_unescape.html curl_free.html curl_strequal.html \ - curl_mprintf.html curl_global_init.html curl_global_cleanup.html \ - curl_multi_add_handle.html curl_multi_cleanup.html curl_multi_fdset.html \ - curl_multi_info_read.html curl_multi_init.html curl_multi_perform.html \ - curl_multi_remove_handle.html curl_share_cleanup.html \ - curl_share_init.html curl_share_setopt.html libcurl.html \ - libcurl-multi.html libcurl-easy.html libcurl-share.html \ - libcurl-errors.html curl_easy_strerror.html curl_multi_strerror.html \ - curl_share_strerror.html curl_global_init_mem.html libcurl-tutorial.html \ - curl_easy_reset.html curl_easy_escape.html curl_easy_unescape.html \ - curl_multi_setopt.html curl_multi_socket.html curl_multi_timeout.html \ - curl_formget.html curl_multi_assign.html curl_easy_pause.html \ - curl_easy_recv.html curl_easy_send.html +HTMLPAGES = curl_easy_cleanup.html curl_easy_getinfo.html \ + curl_easy_init.html curl_easy_perform.html curl_easy_setopt.html \ + curl_easy_duphandle.html curl_formadd.html curl_formfree.html \ + curl_getdate.html curl_getenv.html curl_slist_append.html \ + curl_slist_free_all.html curl_version.html curl_version_info.html \ + curl_escape.html curl_unescape.html curl_free.html curl_strequal.html \ + curl_mprintf.html curl_global_init.html curl_global_cleanup.html \ + curl_multi_add_handle.html curl_multi_cleanup.html \ + curl_multi_fdset.html curl_multi_info_read.html curl_multi_init.html \ + curl_multi_perform.html curl_multi_remove_handle.html \ + curl_share_cleanup.html curl_share_init.html curl_share_setopt.html \ + libcurl.html libcurl-multi.html libcurl-easy.html libcurl-share.html \ + libcurl-errors.html curl_easy_strerror.html curl_multi_strerror.html \ + curl_share_strerror.html curl_global_init_mem.html \ + libcurl-tutorial.html curl_easy_reset.html curl_easy_escape.html \ + curl_easy_unescape.html curl_multi_setopt.html curl_multi_socket.html \ + curl_multi_timeout.html curl_formget.html curl_multi_assign.html \ + curl_easy_pause.html curl_easy_recv.html curl_easy_send.html \ + curl_multi_socket_action.html -PDFPAGES = curl_easy_cleanup.pdf curl_easy_getinfo.pdf curl_easy_init.pdf \ - curl_easy_perform.pdf curl_easy_setopt.pdf curl_easy_duphandle.pdf \ - curl_formadd.pdf curl_formfree.pdf curl_getdate.pdf curl_getenv.pdf \ - curl_slist_append.pdf curl_slist_free_all.pdf curl_version.pdf \ - curl_version_info.pdf curl_escape.pdf curl_unescape.pdf curl_free.pdf \ - curl_strequal.pdf curl_mprintf.pdf curl_global_init.pdf \ - curl_global_cleanup.pdf curl_multi_add_handle.pdf curl_multi_cleanup.pdf \ - curl_multi_fdset.pdf curl_multi_info_read.pdf curl_multi_init.pdf \ - curl_multi_perform.pdf curl_multi_remove_handle.pdf \ - curl_share_cleanup.pdf curl_share_init.pdf curl_share_setopt.pdf \ - libcurl.pdf libcurl-multi.pdf libcurl-easy.pdf libcurl-share.pdf \ - libcurl-errors.pdf curl_easy_strerror.pdf curl_multi_strerror.pdf \ - curl_share_strerror.pdf curl_global_init_mem.pdf libcurl-tutorial.pdf \ - curl_easy_reset.pdf curl_easy_escape.pdf curl_easy_unescape.pdf \ - curl_multi_setopt.pdf curl_multi_socket.pdf curl_multi_timeout.pdf \ - curl_formget.pdf curl_multi_assign.pdf curl_easy_pause.pdf \ - curl_easy_recv.pdf curl_easy_send.pdf +PDFPAGES = curl_easy_cleanup.pdf curl_easy_getinfo.pdf \ + curl_easy_init.pdf curl_easy_perform.pdf curl_easy_setopt.pdf \ + curl_easy_duphandle.pdf curl_formadd.pdf curl_formfree.pdf \ + curl_getdate.pdf curl_getenv.pdf curl_slist_append.pdf \ + curl_slist_free_all.pdf curl_version.pdf curl_version_info.pdf \ + curl_escape.pdf curl_unescape.pdf curl_free.pdf curl_strequal.pdf \ + curl_mprintf.pdf curl_global_init.pdf curl_global_cleanup.pdf \ + curl_multi_add_handle.pdf curl_multi_cleanup.pdf curl_multi_fdset.pdf \ + curl_multi_info_read.pdf curl_multi_init.pdf curl_multi_perform.pdf \ + curl_multi_remove_handle.pdf curl_share_cleanup.pdf curl_share_init.pdf \ + curl_share_setopt.pdf libcurl.pdf libcurl-multi.pdf libcurl-easy.pdf \ + libcurl-share.pdf libcurl-errors.pdf curl_easy_strerror.pdf \ + curl_multi_strerror.pdf curl_share_strerror.pdf \ + curl_global_init_mem.pdf libcurl-tutorial.pdf curl_easy_reset.pdf \ + curl_easy_escape.pdf curl_easy_unescape.pdf curl_multi_setopt.pdf \ + curl_multi_socket.pdf curl_multi_timeout.pdf curl_formget.pdf \ + curl_multi_assign.pdf curl_easy_pause.pdf curl_easy_recv.pdf \ + curl_easy_send.pdf curl_multi_socket_action.pdf CLEANFILES = $(HTMLPAGES) $(PDFPAGES) diff --git a/docs/libcurl/curl_multi_socket.3 b/docs/libcurl/curl_multi_socket.3 index a38532d23..2029e4311 100644 --- a/docs/libcurl/curl_multi_socket.3 +++ b/docs/libcurl/curl_multi_socket.3 @@ -6,14 +6,6 @@ curl_multi_socket \- reads/writes available data .SH SYNOPSIS .nf #include <curl/curl.h> - -CURLMcode curl_multi_socket_action(CURLM * multi_handle, - curl_socket_t sockfd, int ev_bitmask, - int *running_handles); -.fi - -.B "Now deprecated versions:" -.nf CURLMcode curl_multi_socket(CURLM * multi_handle, curl_socket_t sockfd, int *running_handles); @@ -21,19 +13,8 @@ CURLMcode curl_multi_socket_all(CURLM *multi_handle, int *running_handles); .fi .SH DESCRIPTION -Alternative versions of \fIcurl_multi_perform(3)\fP that allows the -application to pass in the file descriptor/socket that has been detected to -have \&"action" on it and let libcurl perform. This lets libcurl avoid having -to scan through all possible file descriptors to check for action. - -When the application has detected action on a socket handled by libcurl, it -should call \fIcurl_multi_socket_action(3)\fP with the \fBsockfd\fP argument -set to the socket with the action. When the events on a socket are known, they -can be passed as an events bitmask \fBev_bitmask\fP by first setting -\fBev_bitmask\fP to 0, and then adding using bitwise OR (|) any combination of -events to be chosen from CURL_CSELECT_IN, CURL_CSELECT_OUT or -CURL_CSELECT_ERR. When the events on a socket are unknown, pass 0 instead, and -libcurl will test the descriptor internally. +These functions are deprecated. Do not use! See +\fIcurl_multi_socket_action(3)\fP instead! At return, the integer \fBrunning_handles\fP points to will contain the number of still running easy handles within the multi handle. When this number diff --git a/docs/libcurl/curl_multi_socket_action.3 b/docs/libcurl/curl_multi_socket_action.3 new file mode 100644 index 000000000..5287b44c3 --- /dev/null +++ b/docs/libcurl/curl_multi_socket_action.3 @@ -0,0 +1,132 @@ +.\" $Id$ +.\" +.TH curl_multi_socket_action 3 "9 Jul 2006" "libcurl 7.16.0" "libcurl Manual" +.SH NAME +curl_multi_socket_action \- reads/writes available data given an action +.SH SYNOPSIS +.nf +#include <curl/curl.h> + +CURLMcode curl_multi_socket_action(CURLM * multi_handle, + curl_socket_t sockfd, int ev_bitmask, + int *running_handles); +.fi +.SH DESCRIPTION +When the application has detected action on a socket handled by libcurl, it +should call \fIcurl_multi_socket_action(3)\fP with the \fBsockfd\fP argument +set to the socket with the action. When the events on a socket are known, they +can be passed as an events bitmask \fBev_bitmask\fP by first setting +\fBev_bitmask\fP to 0, and then adding using bitwise OR (|) any combination of +events to be chosen from CURL_CSELECT_IN, CURL_CSELECT_OUT or +CURL_CSELECT_ERR. When the events on a socket are unknown, pass 0 instead, and +libcurl will test the descriptor internally. + +At return, the integer \fBrunning_handles\fP points to will contain the number +of still running easy handles within the multi handle. When this number +reaches zero, all transfers are complete/done. Note that when you call +\fIcurl_multi_socket_action(3)\fP on a specific socket and the counter +decreases by one, it DOES NOT necessarily mean that this exact socket/transfer +is the one that completed. Use \fIcurl_multi_info_read(3)\fP to figure out +which easy handle that completed. + +The \fBcurl_multi_socket_action(3)\fP functions inform the application about +updates in the socket (file descriptor) status by doing none, one, or multiple +calls to the socket callback function set with the CURLMOPT_SOCKETFUNCTION +option to \fIcurl_multi_setopt(3)\fP. They update the status with changes +since the previous time the callback was called. + +Get the timeout time by setting the \fICURLMOPT_TIMERFUNCTION\fP option with +\fIcurl_multi_setopt(3)\fP. Your application will then get called with +information on how long to wait for socket actions at most before doing the +timeout action: call the \fBcurl_multi_socket_action(3)\fP function with the +\fBsockfd\fP argument set to CURL_SOCKET_TIMEOUT. You can also use the +\fIcurl_multi_timeout(3)\fP function to poll the value at any given time, but +for an event-based system using the callback is far better than relying on +polling the timeout value. +.SH "CALLBACK DETAILS" + +The socket \fBcallback\fP function uses a prototype like this +.nf + + int curl_socket_callback(CURL *easy, /* easy handle */ + curl_socket_t s, /* socket */ + int action, /* see values below */ + void *userp, /* private callback pointer */ + void *socketp); /* private socket pointer */ + +.fi +The callback MUST return 0. + +The \fIeasy\fP argument is a pointer to the easy handle that deals with this +particular socket. Note that a single handle may work with several sockets +simultaneously. + +The \fIs\fP argument is the actual socket value as you use it within your +system. + +The \fIaction\fP argument to the callback has one of five values: +.RS +.IP "CURL_POLL_NONE (0)" +register, not interested in readiness (yet) +.IP "CURL_POLL_IN (1)" +register, interested in read readiness +.IP "CURL_POLL_OUT (2)" +register, interested in write readiness +.IP "CURL_POLL_INOUT (3)" +register, interested in both read and write readiness +.IP "CURL_POLL_REMOVE (4)" +unregister +.RE + +The \fIsocketp\fP argument is a private pointer you have previously set with +\fIcurl_multi_assign(3)\fP to be associated with the \fIs\fP socket. If no +pointer has been set, socketp will be NULL. This argument is of course a +service to applications that want to keep certain data or structs that are +strictly associated to the given socket. + +The \fIuserp\fP argument is a private pointer you have previously set with +\fIcurl_multi_setopt(3)\fP and the CURLMOPT_SOCKETDATA option. +.SH "RETURN VALUE" +CURLMcode type, general libcurl multi interface error code. + +Legacy: If you receive \fICURLM_CALL_MULTI_PERFORM\fP, this basically means +that you should call \fIcurl_multi_socket_action(3)\fP again, before you wait +for more actions on libcurl's sockets. You don't have to do it immediately, +but the return code means that libcurl may have more data available to return +or that there may be more data to send off before it is "satisfied". + +In modern libcurls, \fICURLM_CALL_MULTI_PERFORM\fP or +\fICURLM_CALL_MULTI_SOKCET\fP should not be returned and no application needs +to care about them. + +NOTE that the return code is for the whole multi stack. Problems still might have +occurred on individual transfers even when one of these functions +return OK. +.SH "TYPICAL USAGE" +1. Create a multi handle + +2. Set the socket callback with CURLMOPT_SOCKETFUNCTION + +3. Set the timeout callback with CURLMOPT_TIMERFUNCTION, to get to know what +timeout value to use when waiting for socket activities. + +4. Add easy handles with curl_multi_add_handle() + +5. Provide some means to manage the sockets libcurl is using, so you can check +them for activity. This can be done through your application code, or by way +of an external library such as libevent or glib. + +6. Wait for activity on any of libcurl's sockets, use the timeout value your +callback has been told + +7, When activity is detected, call curl_multi_socket_action() for the +socket(s) that got action. If no activity is detected and the timeout expires, +call \fIcurl_multi_socket_action(3)\fP with \fICURL_SOCKET_TIMEOUT\fP + +8. Go back to step 6. +.SH AVAILABILITY +This function was added in libcurl 7.15.4, and is deemed stable since 7.16.0. +.SH "SEE ALSO" +.BR curl_multi_cleanup "(3), " curl_multi_init "(3), " +.BR curl_multi_fdset "(3), " curl_multi_info_read "(3), " +.BR "the hiperfifo.c example" |