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

Re: [pygame] sockets and events



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
> around it?

it should be pretty quick to just "poll" the socket
and see if there is any new data each frame.

another option would be to create a thread to handle the
network. the thread can parse the data coming on the
socket and post it in a USEREVENT to the event queue.

but i'm not sure the thread and messages will be needed.
it is fast to read data from the socket every frame. if
no data is available, none will be given to you and you
can return very quickly. if there is data, deal with it
right then.

neither of these strategies should be difficult to get
working. whichever you decide to go with you can get
more help here if problems come up :]



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