Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: endless loops for server and tk

by Errto (Vicar)
on Aug 03, 2007 at 04:50 UTC ( #630447=note: print w/replies, xml ) Need Help??


in reply to endless loops for server and tk

A couple of general points. One, yes, add a timeout to your receiving loop. In a similar example, I just used the timeout method of the IO::Socket module. That was for TCP, but I assume there's a UDP equivalent. Second, you can use the fact that you now know you'll iterate through your loop once every some interval, you can use that opportunity to call $mw->update. So the outline is:
# setup MainWindow $mw # setup socket with timeout sub myloop { while (1) { #read from socket; #if anything read, deal with it; $mw->update(); } } $mw->after(1, \&myloop); MainLoop;
This way the main loop initializes itself and renders your window, but then your code takes over and does the GUI update as often as needed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://630447]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2016-10-01 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (7 votes). Check out past polls.