curl-library
Usage of the multi interface with dynamic addition of easy handles
Date: Thu, 26 Sep 2002 18:20:19 +0200
Hello,
I have one question about the subject because the examples covering the multi
interface do not perform something similiar to what I need to do.
Basically, I have to do a select() to wait for events from a TCP listen
channel, and also from the sockets already connected with the clients.
Upon certain events from one or more clients, I need to get an URL using
libcurl, and at the end of each transfer I have to send the received data to
the corresponding client.
I thought about using the multi interface because it allows to make multiple
transfers without using multithreading, and I am able to select() on the
multi handle fd's to call curl_multi_perform only when new data is available.
There's one thing which is not entirely clear to me: after calling
curl_multi_add_handle, the library returns with an explicit code that tells
me to call curl_multi_perform, but simply looping as in the examples until it
returns something different from CURLM_CALL_MULTI_PERFORM could block, not in
the real sense of blocking, because I have read that libcurl is non blocking,
but of transferring (in the worst case) data from each of the easy handles
already associated to that multi handle and not only to the one just added,
and so probably taking more time than necessary ?
I see that using a temporary multi handle is impossible, because
removing the easy handle from it and then adding it to the "main" multi
handle which manages the already "connecting" connections would destroy the
state information about the easy handle (because its state it set to
CURLM_STATE_INIT). Is there a way to avoid this problem without having a (new)
way to tell a multi handle to perform the transfer only on a certain easy
handle, or a set of easy handles ?
Maybe I'm asking silly things, but because I haven't implemented anything yet,
I'd like to have some tips ! :)
Another thing is, when curl_multi_perform returns the number of still running
connections and I see that it has dropped by 1 (or more), is there a simple
way of determining which easy handle(s) finished execution, or do I have to
call curl_multi_info_read continuously and look for all the CURLMsg about
finished easy handles ?
Many thanks in advance !
-- Regards, Fabrizio ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sfReceived on 2002-09-26