Skip to content

Instantly share code, notes, and snippets.

@hryk
Created December 23, 2009 08:29
Show Gist options
  • Save hryk/262399 to your computer and use it in GitHub Desktop.
Save hryk/262399 to your computer and use it in GitHub Desktop.
ping sample with AnyEvent::FastPing
#!/usr/bin/perl
use strict;
use warnings;
use AnyEvent;
use AnyEvent::FastPing;
use Data::Dumper;
my $done = AnyEvent->condvar;
AnyEvent::FastPing::register_cb sub {
my $array = shift;
my @octets = unpack 'C4', $array->[0]->[0];
print "from : ".join('.', @octets )."\n";
print "time : $array->[0]->[1]\n";
print "-----\n";
};
AnyEvent::FastPing::icmp_ping(
[
[v10.16.1.1, v10.16.1.20, .01]
],
.001, 0x12345678,
sub {
warn "All ranges pinged.\n";
$done->broadcast;
}
);
$done->wait;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment