Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

(ichimunki) Re: Querying a Server Periodically

by ichimunki (Priest)
on Dec 28, 2001 at 01:45 UTC ( #134734=note: print w/ replies, xml ) Need Help??


in reply to Querying a Server Periodically

This code could be adapted to a stateless protocol like HTTP for periodic server queries, I think.
#!/usr/bin/perl -w use strict; use Tk; #set up our window and some interactive feature my $mw = Tk::MainWindow->new(); my $button = $mw->Button( -text => 'Pop', -command => sub {print "pop! +\n";} )->pack(); #set up our periodic task. #this executes faithfully every x milliseconds $mw->repeat(5000, \&waiting ); MainLoop; sub waiting { print "waiting...\n"; }
5000 is the milliseconds amount (so it's a very big number for only 5 seconds, but you can also give number as 5 * 1000 to remind yourself and ease figuring out longer intervals. Give this small script a try, as long as you don't mind locking up the client while the updates are happening you don't have to resort to process forking like the Tk chatterbox does.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2016-06-28 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (354 votes). Check out past polls.