Thank you for the reply to my topic, not BASH wars, but does this look
correct?



use IO::Socket;
use strict;
use Time::HiRes qw( time alarm sleep );

$server_ip = 'localhost';
$server_port = 43278;
$microseconds = 5_000_000;

while ( <> ) {

my $message =
IO::Socket::INET->new(Proto=>"udp",PeerPort=>$server_port,PeerAddr=>$server_
ip)
  or die "Can't make UDP socket: $@";
$message->send("PyHB!");

sleep ($microseconds);

}

-Dave

"Dave Gray" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > was wondering if there were a translation in PERL so I could have my
Netware
> > servers send heartbeats to the heartbeat server?
> >
> >       Title: PyHeartbeat - detecting inactive computers
> >       Submitter: Nicola Larosa
> >
> >       # Filename: HeartbeatClient.py
> >
> >       """Heartbeat client, sends out an UDP packet periodically"""
> >
> >       import socket, time
> >
> >       SERVER_IP = '127.0.0.1'; SERVER_PORT = 43278; BEAT_PERIOD = 5
> >
> >       print ('Sending heartbeat to IP %s , port %d\n'
> >           'press Ctrl-C to stop\n') % (SERVER_IP, SERVER_PORT)
> >       while True:
> >           hbSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> >           hbSocket.sendto('PyHB', (SERVER_IP, SERVER_PORT))
> >           if __debug__: print 'Time: %s' % time.ctime()
> >           time.sleep(BEAT_PERIOD)
>
> Checkout Socket [1] and Time::HiRes [2], both of which should be
> installed already, depending on what version of perl you're working
> with. The rest should be fairly simple to translate by following the
> code examples. Let us know how that works out for you.
>
> [1] <http://search.cpan.org/~nwclark/perl-5.8.6/ext/Socket/Socket.pm>
> [2] <http://search.cpan.org/~jhi/Time-HiRes-1.66/HiRes.pm>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to