line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Async::Ping; |
2
|
|
|
|
|
|
|
$Net::Async::Ping::VERSION = '0.002000'; |
3
|
1
|
|
|
1
|
|
23910
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: asyncronously check remote host for reachability |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
775
|
use Module::Runtime 'use_module'; |
|
1
|
|
|
|
|
2064
|
|
|
1
|
|
|
|
|
36
|
|
9
|
1
|
|
|
1
|
|
798
|
use namespace::clean; |
|
1
|
|
|
|
|
17761
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %method_map = ( |
12
|
|
|
|
|
|
|
tcp => 'TCP', |
13
|
|
|
|
|
|
|
icmp => 'ICMP', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
4
|
|
|
4
|
1
|
17819
|
my $class = shift; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
50
|
|
|
24
|
my $method = shift || 'tcp'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
die "The '$method' proto of Net::Ping not ported yet" |
22
|
4
|
50
|
|
|
|
25
|
unless $method_map{$method}; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
9
|
my @args; |
25
|
4
|
50
|
|
|
|
29
|
if (ref $_[0]) { |
26
|
4
|
|
|
|
|
6
|
@args = (%{$_[0]}) |
|
4
|
|
|
|
|
33
|
|
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
0
|
my ($default_timeout, $bytes, $device, $tos, $ttl) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
0
|
@args = ( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
31
|
|
|
|
|
|
|
(@_ >= 1 ? (default_timeout => $default_timeout) : ()), |
32
|
|
|
|
|
|
|
(@_ >= 2 ? (bytes => $bytes) : ()), |
33
|
|
|
|
|
|
|
(@_ >= 3 ? (device => $device) : ()), |
34
|
|
|
|
|
|
|
(@_ >= 4 ? (tos => $tos) : ()), |
35
|
|
|
|
|
|
|
(@_ >= 5 ? (ttl => $ttl) : ()), |
36
|
|
|
|
|
|
|
) |
37
|
|
|
|
|
|
|
} |
38
|
4
|
|
|
|
|
68
|
use_module('Net::Async::Ping::' . $method_map{$method})->new(@args) |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |