[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] sockets and events



On Fri, 10 Aug 2001, Doug Partridge wrote:

>
>I would like to have an event put on the event queue whenever data becomes
>avaliable on a socket for reading. Is this possible? If not, what is the
>best way to work arround it?

I'd check out the "select" module and in your main event loop poll the
socket using select() at regular intervals. If data arrives on the socket
create a new USEREVENT and pygame.event.post() it on the event queue and
handle normally. We've had some problems with USEREVENT:s, so therein may
be dragons. :)

Another method is to use a separate thread for the socket handling, and
somehow have that thread in a safe manner pygame.event.post() USEREVENT:s,
or using some other mean handle the event.

Just some random thoughts.

-----------------------------------------------------------------------------
      Real children don't go hoppity-skip unless they are on drugs.
           -- Susan Sto Helit, in Hogfather (Terry Pratchett)

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org