Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

(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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://134734]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2018-04-24 23:50 GMT
Find Nodes?
    Voting Booth?