line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Selenium::CanStartBinary::ProbePort; |
2
|
|
|
|
|
|
|
$Selenium::CanStartBinary::ProbePort::VERSION = '1.48'; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Utility functions for finding open ports to eventually bind to |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use IO::Socket::INET; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
9
|
1
|
|
|
1
|
|
1136
|
use Selenium::Waiter qw/wait_until/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
237
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw/find_open_port_above find_open_port probe_port/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub find_open_port_above { |
17
|
0
|
|
|
0
|
0
|
|
socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp")); |
18
|
0
|
|
|
|
|
|
bind(SOCK, sockaddr_in(0, INADDR_ANY)); |
19
|
0
|
|
|
|
|
|
my $port = (sockaddr_in(getsockname(SOCK)))[0]; |
20
|
0
|
|
|
|
|
|
close(SOCK); |
21
|
0
|
|
|
|
|
|
return $port; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub find_open_port { |
25
|
0
|
|
|
0
|
0
|
|
my ($port) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
probe_port($port) ? return 0 : return $port; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub probe_port { |
31
|
0
|
|
|
0
|
0
|
|
my ($port) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return IO::Socket::INET->new( |
34
|
|
|
|
|
|
|
PeerAddr => '127.0.0.1', |
35
|
|
|
|
|
|
|
PeerPort => $port, |
36
|
|
|
|
|
|
|
Timeout => 3 |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |