| 1 | package Selenium::CanStartBinary::ProbePort; | ||||||||||
| 2 | 11 | $Selenium::CanStartBinary::ProbePort::VERSION = '1.49'; | |||||||||
| 3 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: Utility functions for finding open ports to eventually bind to | ||||||||||
| 7 | |||||||||||
| 8 | 11 | ▶ | use IO::Socket::INET; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 11 | ▶ | use Selenium::Waiter qw/wait_until/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 11 | require Exporter; | |||||||||
| 12 | 11 | our @ISA = qw/Exporter/; | |||||||||
| 13 | 11 | our @EXPORT_OK = qw/find_open_port_above find_open_port probe_port/; | |||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | sub find_open_port_above { | ||||||||||
| 17 | 0 | ▶ | socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp")); | ||||||||
|
Subroutine
find_open_port_above: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 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 | ▶ | my ($port) = @_; | ||||||||
|
Subroutine
find_open_port: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | probe_port($port) ? return 0 : return $port; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | sub probe_port { | ||||||||||
| 31 | 0 | ▶ | my ($port) = @_; | ||||||||
|
Subroutine
probe_port: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 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__ | ||||||||||
| 41 | |||||||||||
| 42 | =pod | ||||||||||
| 43 | |||||||||||
| 44 | =encoding UTF-8 | ||||||||||
| 45 | |||||||||||
| 46 | =head1 NAME | ||||||||||
| 47 | |||||||||||
| 48 | Selenium::CanStartBinary::ProbePort - Utility functions for finding open ports to eventually bind to | ||||||||||
| 49 | |||||||||||
| 50 | =head1 VERSION | ||||||||||
| 51 | |||||||||||
| 52 | version 1.49 | ||||||||||
| 53 | |||||||||||
| 54 | =for Pod::Coverage *EVERYTHING* | ||||||||||
| 55 | |||||||||||
| 56 | =head1 AUTHORS | ||||||||||
| 57 | |||||||||||
| 58 | Current Maintainers: | ||||||||||
| 59 | |||||||||||
| 60 | =over 4 | ||||||||||
| 61 | |||||||||||
| 62 | =item * | ||||||||||
| 63 | |||||||||||
| 64 | George S. Baugh <george@troglodyne.net> | ||||||||||
| 65 | |||||||||||
| 66 | =back | ||||||||||
| 67 | |||||||||||
| 68 | Previous maintainers: | ||||||||||
| 69 | |||||||||||
| 70 | =over 4 | ||||||||||
| 71 | |||||||||||
| 72 | =item * | ||||||||||
| 73 | |||||||||||
| 74 | Daniel Gempesaw <gempesaw@gmail.com> | ||||||||||
| 75 | |||||||||||
| 76 | =item * | ||||||||||
| 77 | |||||||||||
| 78 | Emmanuel Peroumalnaïk <peroumalnaik.emmanuel@gmail.com> | ||||||||||
| 79 | |||||||||||
| 80 | =item * | ||||||||||
| 81 | |||||||||||
| 82 | Luke Closs <cpan@5thplane.com> | ||||||||||
| 83 | |||||||||||
| 84 | =item * | ||||||||||
| 85 | |||||||||||
| 86 | Mark Stosberg <mark@stosberg.com> | ||||||||||
| 87 | |||||||||||
| 88 | =back | ||||||||||
| 89 | |||||||||||
| 90 | Original authors: | ||||||||||
| 91 | |||||||||||
| 92 | =over 4 | ||||||||||
| 93 | |||||||||||
| 94 | =item * | ||||||||||
| 95 | |||||||||||
| 96 | Aditya Ivaturi <ivaturi@gmail.com> | ||||||||||
| 97 | |||||||||||
| 98 | =back | ||||||||||
| 99 | |||||||||||
| 100 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 101 | |||||||||||
| 102 | Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child | ||||||||||
| 103 | |||||||||||
| 104 | Copyright (c) 2014-2017 Daniel Gempesaw | ||||||||||
| 105 | |||||||||||
| 106 | Copyright (c) 2018-2021 George S. Baugh | ||||||||||
| 107 | |||||||||||
| 108 | Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| 109 | you may not use this file except in compliance with the License. | ||||||||||
| 110 | You may obtain a copy of the License at | ||||||||||
| 111 | |||||||||||
| 112 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| 113 | |||||||||||
| 114 | Unless required by applicable law or agreed to in writing, software | ||||||||||
| 115 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| 116 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| 117 | See the License for the specific language governing permissions and | ||||||||||
| 118 | limitations under the License. | ||||||||||
| 119 | |||||||||||
| 120 | =cut | ||||||||||