CURLM Chain of events
Date: Thu, 21 Jan 2016 16:49:23 +0000 (UTC)
I'm a bit confused about the semantics and dealing with the various CURLM events.
Here is a high-level description of my setup (Windows). I embedded my questions within.
curl_multi_setopt(curl_m_handle, CURLMOPT_SOCKETFUNCTION, on_socket_callback);
curl_multi_setopt(curl_m_handle, CURLMOPT_TIMERFUNCTION, on_timer_callback);
curl_easy_setopt(curl_e_handle, CURLOPT_WRITEDATA, (void *)file);
curl_easy_setopt(curl_e_handle, CURLOPT_URL, url);
// event loop stuff
// Here curl is telling me via CURL_POLL_IN/OUT that it wants me to tell it
// when the socket is ready for read/write.
// Here curl tells me to give up waiting for socket readiness after Xms
Q1: How does it figure X ?
Q2: When I start my program I noticed curl raises this event 3 times before
raising any other events.. Why is that?
Q3: According to the doc's:
"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 curl_multi_socket_action function with the sockfd argument
set to CURL_SOCKET_TIMEOUT"
"When the curl_multi_socket_action function runs, it informs the application about updates in the socket
(file descriptor) status by doing none, one, or multiple calls to the socket_callback"
What exactly am I supposed to do in socket_callback for this case ?
Since I'm only supposed to pass CURL_SOCKET_TIMEOUT and not sockfd, how would I distinguish this case
(and the socket) from the "register with event loop" case ?
Q4: Similar to Q3 how does curl_multi_socket_action (which invokes socket_callback)
tell curl that now the socket is ready? I didn't write any specific code in socket_callback()
for that to happen but it still appears to work..
Thanks in advance.
List admin: http://cool.haxx.se/list/listinfo/curl-library
Received on 2016-01-21