Tkinter & socket question

Hans Nowak ivnowa at hvision.nl
Sat Jun 19 08:33:54 CEST 1999


On 18 Jun 99, Constantinos A. Kotsokalis wrote:

> On Fri, 18 Jun 1999 21:54:11 GMT, Def P wrote:
> >2) I need to poll the connection periodically, say, every second. This would
> >not have been a problem in console mode... I don't know how to do this in a
> >Tkinter environment though. So, how can I do something every second (or every
> >n milliseconds, or whatever the time span may be)? Are threads the way to go?
> >I haven't used them before.
> 
> Well you can always check for a recv() that returns a zero-length
> buffer. That means that the other end has closed connection.

That is a nice way to detect disconnection, but I think the question 
was, how to receive messages from the other side? In console mode you 
can simply do a while loop with recv() in it and check what comes 
back. This is not so straightforward in Tk, you are either in 
mainloop or in your own loop, and unless there's some special event 
in Tk which can be called periodically, I don't know how to do this 
either.

--Hans Nowak (ivnowa at hvision.nl)
Homepage: http://fly.to/zephyrfalcon




More information about the Python-list mailing list