line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Prober::tcp; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Net::Prober::tcp::VERSION = '0.15'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
8
|
1
|
|
|
1
|
|
2
|
use base 'Net::Prober::Probe::TCP'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
341
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use Carp (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
11
|
1
|
|
|
1
|
|
3
|
use Net::Prober (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
148
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub probe { |
14
|
2
|
|
|
2
|
0
|
2
|
my ($self, $args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
6
|
my ($host, $port, $timeout, $proto) = |
17
|
|
|
|
|
|
|
$self->parse_args($args, qw(host port timeout proto)); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
6
|
$port = Net::Prober::port_name_to_num($port); |
20
|
|
|
|
|
|
|
|
21
|
2
|
50
|
33
|
|
|
11
|
if (! defined $port or $port == 0) { |
22
|
0
|
|
|
|
|
0
|
Carp::croak("Can't probe: undefined port"); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
50
|
|
|
3
|
$timeout ||= 3.5; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
8
|
my $t0 = $self->time_now(); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
6
|
my $sock = $self->open_socket($args); |
30
|
2
|
|
|
|
|
1202
|
my $good = 0; |
31
|
2
|
|
|
|
|
2
|
my $reason; |
32
|
|
|
|
|
|
|
|
33
|
2
|
50
|
|
|
|
5
|
if (! $sock) { |
34
|
2
|
|
|
|
|
2
|
$reason = "Socket open failed"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
0
|
|
|
0
|
$good = $sock->connected() && $sock->close(); |
38
|
0
|
0
|
|
|
|
0
|
if (! $good) { |
39
|
0
|
|
|
|
|
0
|
$reason = "Socket connect or close failed"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
12
|
my $elapsed = $self->time_elapsed(); |
44
|
|
|
|
|
|
|
|
45
|
2
|
50
|
|
|
|
3
|
if ($good) { |
46
|
0
|
|
|
|
|
0
|
return $self->probe_ok( |
47
|
|
|
|
|
|
|
time => $elapsed, |
48
|
|
|
|
|
|
|
host => $host, |
49
|
|
|
|
|
|
|
port => $port, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
9
|
return $self->probe_failed( |
54
|
|
|
|
|
|
|
time => $elapsed, |
55
|
|
|
|
|
|
|
host => $host, |
56
|
|
|
|
|
|
|
port => $port, |
57
|
|
|
|
|
|
|
reason => $reason, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |