curl-library
CURLM Chain of events
Date: Thu, 21 Jan 2016 16:49:23 +0000 (UTC)
Hi!
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_global_init(CURL_GLOBAL_ALL)
curl_multi_setopt(curl_m_handle, CURLMOPT_SOCKETFUNCTION, on_socket_callback);
curl_multi_setopt(curl_m_handle, CURLMOPT_TIMERFUNCTION, on_timer_callback);
curl_easy_init();
curl_easy_setopt(curl_e_handle, CURLOPT_WRITEDATA, (void *)file);
curl_easy_setopt(curl_e_handle, CURLOPT_URL, url);
curl_multi_add_handle(..;
curl_multi_perform(..
// event loop stuff
curl_multi_cleanup(..;
...
socket_callback(
{
// 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.
}
timer_callback(
{
// 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?
}
my_timer_callback(
{
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 ?
}
event_loop_callback(
{
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
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2016-01-21