[python-win32] win32event.WaitForMultipleObjects and sockets

David Markey admin at dmarkey.com
Thu May 26 11:56:57 CEST 2011


I cant seem to find WSACreateEvent anywhere, is it exposed?

There is win32event.CreateEvent but it takes 4 arguments.

I can find win32file.WSAEventSelect alright.


On 26 May 2011 10:05, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:

> 2011/5/26 David Markey <admin at dmarkey.com>:
> > Hi All,
> > Sorry for the n00b question...
> > With win32event.WaitForMultipleObjects, I dont seem to be able to give it
> a
> > plain socket object. How can I create a PyHANDLE from a socket?
>
> It won't work like this, because a socket has several things you
> can wait for (available for read, available for write, accept, error,
> and probably others)
>
> You should use WSAEventSelect() to associate a socket with a handle.
>
> This is pseudo-code (I don't have Windows at the moment, sorry)::
>
>    socket_event = WSACreateEvent()
>    WSAEventSelect(mysocket, socket_event, FD_READ | FD_CLOSE)
>    ... then socket_event may be used in WaitForMultipleObjects...
>    WSACloseEvent(socket_event)
>
>
> --
> Amaury Forgeot d'Arc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110526/1223fa1a/attachment.html>


More information about the python-win32 mailing list