Arthur Axel "fREW" Schmidt > Net-Async-Ping-0.001000 > Net::Async::Ping

Download:
Net-Async-Ping-0.001000.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.001000   Source  

NAME ^

Net::Async::Ping - asyncronously check remote host for reachability

VERSION ^

version 0.001000

SYNOPSIS ^

 use IO::Async::Loop;
 use Net::Async::Ping;

 my $p = Net::Async::Ping->new;
 my $loop = IO::Async::Loop->new;

 my $future = $p->ping($loop, 'myrealbox.com');

 $future->on_done(sub {
    say "good job the host is running!"
 });
 $future->on_fail(sub {
    say "the host is down!!!";
 });

DESCRIPTION ^

This module's goal is to eventually be able to test remote hosts on a network with a number of different socket types and protocols. Currently it only supports TCP, but UDP, ICMP, and Syn are planned. If you need one of those feel free to work up a patch.

This module was originally forked off of Net::Ping, so it shares some of it's interface, but only where it makes sense.

METHODS ^

new

 my $p = Net::Async::Ping->new(
   $proto, $def_timeout, $bytes, $device, $tos, $ttl,
 );

All arguments to new are optional, but if you want to provide one in the middle you must provide all the ones to the left of it. The default (and currently only) protocol is tcp. The default timeout is 5 seconds. bytes does not apply to tcp. device is what host to bind the socket to, ie what to ping from. Neither tos nor ttl apply to tcp currently.

Alternately, you can use a new constructor:

 my $p = Net::Async::Ping->new(
   tcp => {
      default_timeout => 10,
      bind            => '192.168.1.1',
      port_number     => 80,
      service_check   => 1,
   },
 );

All of the above arguments are optional. Service check, which is off by default, will cause ping to fail if the host refuses connection to the selected port (7 by default.) Bind is the same as device from before. =method ping

 my $future = $p->ping($loop, $host, $timeout);

Returns a Future representing the ping. loop should be an IO::Async::Loop, host is the host, and timeout is optional and defaults to the default set above.

The future will always terminate with the hi resolution time it took to check for liveness. The success or failure is checked by introspecting the future itself.

AUTHOR ^

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: