cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: using WSAEventSelect with curl multi

From: Jamie Lokier <jamie_at_shareable.org>
Date: Tue, 1 Dec 2009 22:02:50 +0000

Oran Agra wrote:
> >The multi interface is not blocking...
>
> Right sorry, I was using multi with curl_multi_fdset and select (code from the fopen.c sample), which made the code achieve blocking.
>
> >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?
>
> Right in windows select works only on sockets, and
> WaitForMultipleObjects work on other handles. This is why I want to
> use WSAEventSelect which associates (I think) a socket with an event
> (that can be then used with WaitForMultipleObjects)

There are a multitude of ways to wait for both (or schedule actions on
both) on Windows. WSAEventSelect should be ok; it has only the slight
flaw that (I have read) it can lose events if the event queue reaches
it's maximum size. But that shouldn't happen if the number of sockets
is small.

> >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?
>
> I'm not sure if I'm using curl the correct way (curl_multi_preform vs curl_multi_socket_action vs curl_multi_socket_all), and I'm not sure I'm using Win32 API correctly (WSAEventSelect).
> This is why I ask if someone has a sample that does what I'm trying to do (on windows)

I haven't done it. But I know select() is effectively
level-triggered, and Winsock events are edge-triggered; could it be
that you need to set a persistent "I have received Readable event"
flag (which is set initially) and only clear it on WSAEWOULDBLOCK when
reading, plus the same for writing?

-- Jamie
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-01