On Tue, 1 Dec 2009, Oran Agra wrote:

I'm trying to use cURL multi on Windows Mobile.
Both easy and multi work well in blocking mode.

The multi interface is not blocking...

This said: I don't know windows (mobile) details so please bear with me. I do however know a bit about the libcurl internals.

I'm trying to create a worker thread that can handle multiple transfers, and receive commends (like quit) from other threads.

I've started with portions of the fopen.c sample that comes with curl, which uses curl_multi_fdset, select, and then curl_multi_perform.

I figured I need to replace the curl_multi_fdset+select with a WaitForMultipleObjects, and use WSAEventSelect to associate the socket with an event.

Why? Oh, is that because you only can select() on sockets in windows and you want to wait for that quit command using some other means?

Isn't WaitForMultipleObjects() however just a different select call so that it can wait for a number of sockets and some other file handles?

I thought I need to use curl_multi_setopt with CURLMOPT_SOCKETFUNCTION and maybe also with CURLMOPT_TIMERFUNCTION, the first of which (according to my understanding should give me a socket handle after the socket is created so that I can call WSAEventSelect).

Yes, you can set those but if you want the "raw" sockets you must use the curl_multi_socket_action() function instead of curl_multi_perform().

I soon discovered that the CURLMOPT_SOCKETFUNCTION callback isn't called at all when using curl_multi_perform, and searching in the samples I saw the only samples that use this callback are using curl_multi_socket_all instead (a deprecated function).

Two flaws on our behalf: 1) we should document that CURLMOPT_SOCKETFUNCTION is for the multi_socket API and 2) we should fix the examples to not use deprecated functions.

(I'll appreciate patches!)

I've tried using curl_multi_socket_all instead of curl_multi_perform, and my callback started to happen, but later when I do WaitForMultipleObjects or WSAWaitForMultipleEvents it never goes out from that call.

So do they wait for the sockets the correct way? If so, why don't they return? Don't the socket(s) get any action? If they do, isn't that a sign you don't wait for them the correct way? If they don't, isn't that a sign something is seriously wrong?

Btw, the call to WSAEventSelect returned with success.

I don't understand the difference or the importance with WSAWaitForMultipleEvents and WSAEventSelect so I'm afraid those subtleties get lost for me.

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to