cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_socket_action, http pipelining

From: George Kola <kolatmp_at_gmail.com>
Date: Sun, 17 Aug 2008 17:47:33 -0700

*>> I)First question is about step 3. Documentation (http:// *
*>> curl.haxx.se/libcurl/c/curl_multi_socket.html) says there should be *
*>> no reason to use curl_multi_socket_all. If I am not to use it, what *
*>> should I use in step 3 (curl_multi_perform ?) *

>You don't need to call curl_multi_socket_all, anytime you think you
>need to call it must be considered a bug somewhere. Adding the easy
?handle should generate a socket and/or timeout callback, so you can
>add the socket to your event backend. When the socket becomes
>readable or writable, you call curl_multi_socket_action on it. You
>don't manually have to "start" the transfer. At least I never did.

        I find that when I add an easy handle to multi handle, only the
timeout callback (set with CURLMOPT_TIMERFUNCTION) is called with a timeout
of 0 and the socket callback is not called. Is this normal ?

I am using this
static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp) ;
as the timeout call back prototype. (copied from ghiper.c example)

         I now have my code set a flag if timeout_ms==0 and after adding an
handle to multi handle, I check this flag and call curl_multi_socket_action
with CURL_SOCKET_TIMEOUT. Is this the correct way ?

        I find that after the first call with CURL_SOCKET_TIMEOUT, the
timeout_ms passes is 299,999 -- this seems a long time (almost 5 minutes).
Am I doing something wrong ?

         I also find that on every further addition of an easy handle,
the CURLMOPT_TIMERFUNCTION
gets called with a timeout of 0. So, should I keep calling call
curl_multi_socket_action with CURL_SOCKET_TIMEOUT on every addition of an
easy handle to a multi handle.

Thanks,
George
Received on 2008-08-18