/usr/local/lib/perl5/5.44.0/x86_64-linux/IO/Socket/INET.pm

filter: Statementstmt 18.3% 29 / 158 Branchbran 2.9% 4 / 134 Conditioncond 0.0% 0 / 68 MC/DCmcdc 0.0% 0 / 40 Subroutinesub 27.2% 6 / 22 Podpod 80.0% 8 / 10 totaltotal 10.8% 47 / 432 CC 90 SCAR 66.1
CC
90
Cov
9%
configure
1806.0
_sock_info
342.0
_get_proto_number
20.0
CRAP 745.0
« /usr/local/lib/perl5/site_perl/5.44.0/Method/Generate/Accessor.pm ↑ Summary /usr/local/lib/perl5/5.44.0/constant.pm »
1 # IO::Socket::INET.pm
2 #
3 # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the same terms as Perl itself.
6  
7 package IO::Socket::INET;
8  
9 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use Errno;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 our @ISA = qw(IO::Socket);
17 5 our $VERSION = "1.56";
18  
19 5 ▶my $EINVAL = exists(&Errno::EINVAL) ? Errno::EINVAL() : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists &Errno::EINVAL ? : 5 0 5
20  
21 5 IO::Socket::INET->register_domain( AF_INET );
22  
23 5 my %socket_type = ( tcp => SOCK_STREAM,
24 udp => SOCK_DGRAM,
25 icmp => SOCK_RAW
26 );
27 5 my %proto_number;
28 5 ▶$proto_number{tcp} = Socket::IPPROTO_TCP() if defined &Socket::IPPROTO_TCP;
Branch: 1 branch
BranchTrueFalseTotal
if defined &Socket::IPPROTO_TCP 5 0 5
29 5 ▶$proto_number{udp} = Socket::IPPROTO_UDP() if defined &Socket::IPPROTO_UDP;
Branch: 1 branch
BranchTrueFalseTotal
if defined &Socket::IPPROTO_UDP 5 0 5
30 5 ▶$proto_number{icmp} = Socket::IPPROTO_ICMP() if defined &Socket::IPPROTO_ICMP;
Branch: 1 branch
BranchTrueFalseTotal
if defined &Socket::IPPROTO_ICMP 5 0 5
31 5 my %proto_name = reverse %proto_number;
32  
33 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
34 0 my $class = shift;
35 0 ▶ unshift(@_, "PeerAddr") if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
36 0 return $class->SUPER::new(@_);
37 }
38  
39 0 ▶sub _cache_proto {
Subroutine _cache_proto: not called CC=2 SCAR=17.9
40 0 my @proto = @_;
41 0 for (map lc($_), $proto[0], split(' ', $proto[1])) {
42 0 $proto_number{$_} = $proto[2];
43 }
44 0 $proto_name{$proto[2]} = $proto[0];
45 }
46  
47 0 ▶sub _get_proto_number {
Subroutine _get_proto_number: not called CC=4 SCAR=30.0
48 0 my $name = lc(shift);
49 0 ▶ return undef unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 0 0
50 0 ▶ return $proto_number{$name} if exists $proto_number{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $proto_number{$name} 0 0 0
51  
52 0 my @proto = eval { getprotobyname($name) };
53 0 ▶ return undef unless @proto;
Branch: 1 branch
BranchTrueFalseTotal
unless @proto 0 0 0
54 0 _cache_proto(@proto);
55  
56 0 return $proto[2];
57 }
58  
59 0 ▶sub _get_proto_name {
Subroutine _get_proto_name: not called CC=4 SCAR=30.0
60 0 my $num = shift;
61 0 ▶ return undef unless defined $num;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $num 0 0 0
62 0 ▶ return $proto_name{$num} if exists $proto_name{$num};
Branch: 1 branch
BranchTrueFalseTotal
if exists $proto_name{$num} 0 0 0
63  
64 0 my @proto = eval { getprotobynumber($num) };
65 0 ▶ return undef unless @proto;
Branch: 1 branch
BranchTrueFalseTotal
unless @proto 0 0 0
66 0 _cache_proto(@proto);
67  
68 0 return $proto[0];
69 }
70  
71 0 ▶sub _sock_info {
Subroutine _sock_info: not called CC=18 SCAR=58.3
72 0 my($addr,$port,$proto) = @_;
73 0 my $origport = $port;
74 0 my @serv = ();
75  
76 0 ▶ $port = $1
Branch: 1 branch
BranchTrueFalseTotal
if defined $addr and $addr =~ s[:([\w\(\)/]+)$][] 0 0 0
Condition0%0/3
defined $addr and $addr =~ s[:([\w\(\)/]+)$][]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $addr and $addr =~ s[:([\w\(\)/]+)$][]
defined $addr $addr =~ s[:([\w\(\)/]+)$][]
Truth table0%0/3
A and B
A= defined $addrB= $addr =~ s[:([\w\(\)/]+)$][]
ABresult
0X0
100
111
77 if(defined $addr && $addr =~ s,:([\w\(\)/]+)$,,);
78  
79 0 ▶ if(defined $proto && $proto =~ /\D/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proto and $proto =~ /\D/) 0 0 0
Condition0%0/3
defined $proto and $proto =~ /\D/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proto and $proto =~ /\D/
defined $proto $proto =~ /\D/
Truth table0%0/3
A and B
A= defined $protoB= $proto =~ /\D/
ABresult
0X0
100
111
80 0 my $num = _get_proto_number($proto);
81 0 ▶ unless (defined $num) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
82 0 $IO::Socket::errstr = $@ = "Bad protocol '$proto'";
83 0 return;
84 }
85 0 $proto = $num;
86 }
87  
88 0 ▶ if(defined $port) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $port) 0 0 0
89 0 ▶ my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
$port =~ s/\((\d+)\)$// ? : 0 0 0
90 0 my $pnum = ($port =~ m,^(\d+)$,)[0];
91  
92 0 ▶ @serv = getservbyname($port, _get_proto_name($proto) || "")
Branch: 1 branch
BranchTrueFalseTotal
if $port =~ /\D/ 0 0 0
Condition0%0/2
_get_proto_name($proto) || ''
l!l
00
MC/DC0%0/1
_get_proto_name($proto) || ''
_get_proto_name($proto)
Truth table0%0/2
A
A= _get_proto_name($proto)
Aresult
11
00
93 if ($port =~ m,\D,);
94  
95 0 ▶ $port = $serv[2] || $defport || $pnum;
Condition0%0/6
$serv[2] || $defport || $pnum
l!l&&r!l&&!r
000
$serv[2] or $defport
l!l&&r!l&&!r
000
MC/DC0%0/3
$serv[2] || $defport || $pnum
$serv[2] $defport $pnum
Truth table0%0/4
A or B || C
A= $serv[2]B= $defportC= $pnum
ABCresult
1XX1
01X1
0011
0000
96 0 ▶ unless (defined $port) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $port) 0 0 0
97 0 $IO::Socket::errstr = $@ = "Bad service '$origport'";
98 0 return;
99 }
100  
101 0 ▶ $proto = _get_proto_number($serv[3]) if @serv && !$proto;
Branch: 1 branch
BranchTrueFalseTotal
if @serv and not $proto 0 0 0
Condition0%0/3
@serv and not $proto
!ll&&!rl&&r
000
MC/DC0%0/2
@serv and not $proto
@serv not $proto
Truth table0%0/3
A and not(B)
A= @servB= not $proto
ABresult
0X0
100
111
102 }
103  
104 0 ▶ return ($addr || undef,
Condition0%0/6
$addr || undef
l!l
00
$port || undef
l!l
00
$proto || undef
l!l
00
MC/DC0%0/1
$addr || undef
$addr
MC/DC0%0/1
$port || undef
$port
MC/DC0%0/1
$proto || undef
$proto
Truth table0%0/2
A
A= $addr
Aresult
11
00
Truth table0%0/2
A
A= $port
Aresult
11
00
Truth table0%0/2
A
A= $proto
Aresult
11
00
105 $port || undef,
106 $proto || undef
107 );
108 }
109  
110 0 ▶sub _error {
Subroutine _error: not called CC=3 SCAR=24.8
111 0 my $sock = shift;
112 0 my $err = shift;
113 {
114 0 local($!);
115 0 my $title = ref($sock).": ";
116 0 ▶ $IO::Socket::errstr = $@ = join("", $_[0] =~ /^$title/ ? "" : $title, @_);
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^$title/ ? : 0 0 0
117 0 ▶ $sock->close()
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $sock 0 0 0
118 if(defined fileno($sock));
119 }
120 0 $! = $err;
121 0 return undef;
122 }
123  
124 0 ▶sub _get_addr {
Subroutine _get_addr: not called CC=4 SCAR=30.0
125 0 my($sock,$addr_str, $multi) = @_;
126 0 my @addr;
127 0 ▶ if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($multi and not $addr_str =~ /^\d+(?:\.\d+){3}$/) { } 0 0 0
Condition0%0/3
$multi and not $addr_str =~ /^\d+(?:\.\d+){3}$/
!ll&&!rl&&r
000
MC/DC0%0/2
$multi and not $addr_str =~ /^\d+(?:\.\d+){3}$/
$multi not $addr_str =~ /^\d+(?:\.\d+){3}$/
Truth table0%0/3
A and not(B)
A= $multiB= not $addr_str =~ /^\d+(?:\.\d+){3}$/
ABresult
0X0
100
111
128 0 (undef, undef, undef, undef, @addr) = gethostbyname($addr_str);
129 } else {
130 0 my $h = inet_aton($addr_str);
131 0 ▶ push(@addr, $h) if defined $h;
Branch: 1 branch
BranchTrueFalseTotal
if defined $h 0 0 0
132 }
133 0 @addr;
134 }
135  
136 0 ▶sub configure {
Subroutine configure: not called CC=42 SCAR=75.0
Pod undocumented
137 0 my($sock,$arg) = @_;
138 0 my($lport,$rport,$laddr,$raddr,$proto,$type);
139  
140  
141 $arg->{LocalAddr} = $arg->{LocalHost}
142 0 ▶ if exists $arg->{LocalHost} && !exists $arg->{LocalAddr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"} 0 0 0
Condition0%0/3
exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"}
exists $arg->{"LocalHost"} not exists $arg->{"LocalAddr"}
Truth table0%0/3
A and not(B)
A= exists $arg->{"LocalHost"}B= not exists $arg->{"LocalAddr"}
ABresult
0X0
100
111
143  
144 ($laddr,$lport,$proto) = _sock_info($arg->{LocalAddr},
145 $arg->{LocalPort},
146 $arg->{Proto})
147 0 ▶ or return _error($sock, $!, $@);
Branch: 1 branch
BranchTrueFalseTotal
($laddr, $lport, $proto) = _sock_info($arg->{"LocalAddr"}, $arg->{"LocalPort"}, $arg->{"Proto"}) or return _error($sock, $!, $@) 0 0 0
148  
149 0 ▶ $laddr = defined $laddr ? inet_aton($laddr)
Branch: 1 branch
BranchTrueFalseTotal
defined $laddr ? : 0 0 0
150 : INADDR_ANY;
151  
152 0 ▶ return _error($sock, $EINVAL, "Bad hostname '",$arg->{LocalAddr},"'")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $laddr 0 0 0
153 unless(defined $laddr);
154  
155 $arg->{PeerAddr} = $arg->{PeerHost}
156 0 ▶ if exists $arg->{PeerHost} && !exists $arg->{PeerAddr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"} 0 0 0
Condition0%0/3
exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"}
exists $arg->{"PeerHost"} not exists $arg->{"PeerAddr"}
Truth table0%0/3
A and not(B)
A= exists $arg->{"PeerHost"}B= not exists $arg->{"PeerAddr"}
ABresult
0X0
100
111
157  
158 0 ▶ unless(exists $arg->{Listen}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $arg->{"Listen"}) 0 0 0
159 ($raddr,$rport,$proto) = _sock_info($arg->{PeerAddr},
160 $arg->{PeerPort},
161 0 ▶ $proto)
Branch: 1 branch
BranchTrueFalseTotal
($raddr, $rport, $proto) = _sock_info($arg->{"PeerAddr"}, $arg->{"PeerPort"}, $proto) or return _error($sock, $!, $@) 0 0 0
162 or return _error($sock, $!, $@);
163 }
164  
165 0 ▶ $proto ||= _get_proto_number('tcp');
Condition0%0/3
$proto ||= _get_proto_number("tcp")
l!l&&r!l&&!r
000
MC/DC0%0/2
$proto ||= _get_proto_number("tcp")
$proto _get_proto_number("tcp")
Truth table0%0/3
A ||= B
A= $protoB= _get_proto_number("tcp")
ABresult
1X1
011
000
166  
167 0 ▶ $type = $arg->{Type} || $socket_type{lc _get_proto_name($proto)};
Condition0%0/3
$arg->{'Type'} || $socket_type{lc _get_proto_name($proto)}
l!l&&r!l&&!r
000
MC/DC0%0/2
$arg->{'Type'} || $socket_type{lc _get_proto_name($proto)}
$arg->{'Type'} $socket_type{lc _get_proto_name($proto)}
Truth table0%0/3
A || B
A= $arg->{'Type'}B= $socket_type{lc _get_proto_name($proto)}
ABresult
1X1
011
000
168  
169 0 my @raddr = ();
170  
171 0 ▶ if(defined $raddr) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $raddr) 0 0 0
172 0 @raddr = $sock->_get_addr($raddr, $arg->{MultiHomed});
173 0 ▶ return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'")
Branch: 1 branch
BranchTrueFalseTotal
unless @raddr 0 0 0
174 unless @raddr;
175 }
176  
177 0 while(1) {
178  
179 0 ▶ $sock->socket(AF_INET, $type, $proto) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->socket(2, $type, $proto) or return _error($sock, $!, "$!") 0 0 0
180 return _error($sock, $!, "$!");
181  
182 0 ▶ if (defined $arg->{Blocking}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg->{"Blocking"}) 0 0 0
183 defined $sock->blocking($arg->{Blocking})
184 0 ▶ or return _error($sock, $!, "$!");
Branch: 1 branch
BranchTrueFalseTotal
defined $sock->blocking($arg->{"Blocking"}) or return _error($sock, $!, "$!") 0 0 0
185 }
186  
187 0 ▶ if ($arg->{Reuse} || $arg->{ReuseAddr}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"Reuse"} or $arg->{"ReuseAddr"}) 0 0 0
Condition0%0/3
$arg->{"Reuse"} or $arg->{"ReuseAddr"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$arg->{"Reuse"} or $arg->{"ReuseAddr"}
$arg->{"Reuse"} $arg->{"ReuseAddr"}
Truth table0%0/3
A or B
A= $arg->{"Reuse"}B= $arg->{"ReuseAddr"}
ABresult
1X1
011
000
188 0 ▶ $sock->sockopt(SO_REUSEADDR,1) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->sockopt(2, 1) or return _error($sock, $!, "$!") 0 0 0
189 return _error($sock, $!, "$!");
190 }
191  
192 0 ▶ if ($arg->{ReusePort}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"ReusePort"}) 0 0 0
193 0 ▶ $sock->sockopt(SO_REUSEPORT,1) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->sockopt(15, 1) or return _error($sock, $!, "$!") 0 0 0
194 return _error($sock, $!, "$!");
195 }
196  
197 0 ▶ if ($arg->{Broadcast}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"Broadcast"}) 0 0 0
198 0 ▶ $sock->sockopt(SO_BROADCAST,1) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->sockopt(6, 1) or return _error($sock, $!, "$!") 0 0 0
199 return _error($sock, $!, "$!");
200 }
201  
202 0 ▶ if($lport || ($laddr ne INADDR_ANY) || exists $arg->{Listen}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lport or $laddr ne "\0\0\0\0" or exists $arg->{"Listen"}) 0 0 0
Condition0%0/6
$lport or $laddr ne "\0\0\0\0" or exists $arg->{"Listen"}
l!l&&r!l&&!r
000
$lport or $laddr ne "\0\0\0\0"
l!l&&r!l&&!r
000
MC/DC0%0/3
$lport or $laddr ne "\0\0\0\0" or exists $arg->{"Listen"}
$lport $laddr ne "\0\0\0\0" exists $arg->{"Listen"}
Truth table0%0/4
A or B or C
A= $lportB= $laddr ne "\0\0\0\0"C= exists $arg->{"Listen"}
ABCresult
1XX1
01X1
0011
0000
203 0 ▶ $sock->bind($lport || 0, $laddr) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->bind($lport || 0, $laddr) or return _error($sock, $!, "$!") 0 0 0
Condition0%0/2
$lport || 0
l!l
00
MC/DC0%0/1
$lport || 0
$lport
Truth table0%0/2
A
A= $lport
Aresult
11
00
204 return _error($sock, $!, "$!");
205 }
206  
207 0 ▶ if(exists $arg->{Listen}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg->{"Listen"}) 0 0 0
208 0 ▶ $sock->listen($arg->{Listen} || 5) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->listen($arg->{"Listen"} || 5) or return _error($sock, $!, "$!") 0 0 0
Condition0%0/2
$arg->{'Listen'} || 5
l!l
00
MC/DC0%0/1
$arg->{'Listen'} || 5
$arg->{'Listen'}
Truth table0%0/2
A
A= $arg->{'Listen'}
Aresult
11
00
209 return _error($sock, $!, "$!");
210 0 last;
211 }
212  
213 # don't try to connect unless we're given a PeerAddr
214 0 ▶ last unless exists($arg->{PeerAddr});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $arg->{"PeerAddr"} 0 0 0
215
216 0 $raddr = shift @raddr;
217  
218 0 ▶ return _error($sock, $EINVAL, 'Cannot determine remote port')
Branch: 1 branch
BranchTrueFalseTotal
unless $rport or $type == 2 or $type == 3 0 0 0
Condition0%0/6
$rport or $type == 2 or $type == 3
l!l&&r!l&&!r
000
$rport or $type == 2
l!l&&r!l&&!r
000
MC/DC0%0/3
$rport or $type == 2 or $type == 3
$rport $type == 2 $type == 3
Truth table0%0/4
A or B or C
A= $rportB= $type == 2C= $type == 3
ABCresult
1XX1
01X1
0011
0000
219 unless($rport || $type == SOCK_DGRAM || $type == SOCK_RAW);
220  
221 last
222 0 ▶ unless($type == SOCK_STREAM || defined $raddr);
Branch: 1 branch
BranchTrueFalseTotal
unless $type == 1 or defined $raddr 0 0 0
Condition0%0/3
$type == 1 or defined $raddr
l!l&&r!l&&!r
000
MC/DC0%0/2
$type == 1 or defined $raddr
$type == 1 defined $raddr
Truth table0%0/3
A or B
A= $type == 1B= defined $raddr
ABresult
1X1
011
000
223  
224 0 ▶ return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $raddr 0 0 0
225 unless defined $raddr;
226  
227 # my $timeout = ${*$sock}{'io_socket_timeout'};
228 # my $before = time() if $timeout;
229  
230 0 undef $@;
231 0 ▶ if ($sock->connect(pack_sockaddr_in($rport, $raddr))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sock->connect(pack_sockaddr_in($rport, $raddr))) 0 0 0
232 # ${*$sock}{'io_socket_timeout'} = $timeout;
233 0 return $sock;
234 }
235  
236 0 ▶ return _error($sock, $!, $@ || "Timeout")
Branch: 1 branch
BranchTrueFalseTotal
unless @raddr 0 0 0
Condition0%0/2
$@ || 'Timeout'
l!l
00
MC/DC0%0/1
$@ || 'Timeout'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
237 unless @raddr;
238  
239 # if ($timeout) {
240 # my $new_timeout = $timeout - (time() - $before);
241 # return _error($sock,
242 # (exists(&Errno::ETIMEDOUT) ? Errno::ETIMEDOUT() : $EINVAL),
243 # "Timeout") if $new_timeout <= 0;
244 # ${*$sock}{'io_socket_timeout'} = $new_timeout;
245 # }
246  
247 }
248  
249 0 $sock;
250 }
251  
252 0 ▶sub connect {
Subroutine connect: not called CC=4 SCAR=30.0
Pod undocumented
253 0 ▶ @_ == 2 || @_ == 3 or
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or croak("usage: \$sock->connect(NAME) or \$sock->connect(PORT, ADDR)") 0 0 0
Condition0%0/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
254 croak 'usage: $sock->connect(NAME) or $sock->connect(PORT, ADDR)';
255 0 my $sock = shift;
256 0 ▶ return $sock->SUPER::connect(@_ == 1 ? shift : pack_sockaddr_in(@_));
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
257 }
258  
259 0 ▶sub bind {
Subroutine bind: not called CC=4 SCAR=30.0
Pod documented
260 0 ▶ @_ == 2 || @_ == 3 or
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or croak("usage: \$sock->bind(NAME) or \$sock->bind(PORT, ADDR)") 0 0 0
Condition0%0/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
261 croak 'usage: $sock->bind(NAME) or $sock->bind(PORT, ADDR)';
262 0 my $sock = shift;
263 0 ▶ return $sock->SUPER::bind(@_ == 1 ? shift : pack_sockaddr_in(@_))
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
264 }
265  
266 0 ▶sub sockaddr {
Subroutine sockaddr: not called CC=3 SCAR=24.8
Pod documented
267 0 ▶ @_ == 1 or croak 'usage: $sock->sockaddr()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->sockaddr()") 0 0 0
268 0 my($sock) = @_;
269 0 my $name = $sock->sockname;
270 0 ▶ $name ? (sockaddr_in($name))[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 0 0 0
271 }
272  
273 0 ▶sub sockport {
Subroutine sockport: not called CC=3 SCAR=24.8
Pod documented
274 0 ▶ @_ == 1 or croak 'usage: $sock->sockport()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->sockport()") 0 0 0
275 0 my($sock) = @_;
276 0 my $name = $sock->sockname;
277 0 ▶ $name ? (sockaddr_in($name))[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 0 0 0
278 }
279  
280 0 ▶sub sockhost {
Subroutine sockhost: not called CC=3 SCAR=24.8
Pod documented
281 0 ▶ @_ == 1 or croak 'usage: $sock->sockhost()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->sockhost()") 0 0 0
282 0 my($sock) = @_;
283 0 my $addr = $sock->sockaddr;
284 0 ▶ $addr ? inet_ntoa($addr) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$addr ? : 0 0 0
285 }
286  
287 0 ▶sub peeraddr {
Subroutine peeraddr: not called CC=3 SCAR=24.8
Pod documented
288 0 ▶ @_ == 1 or croak 'usage: $sock->peeraddr()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->peeraddr()") 0 0 0
289 0 my($sock) = @_;
290 0 my $name = $sock->peername;
291 0 ▶ $name ? (sockaddr_in($name))[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 0 0 0
292 }
293  
294 0 ▶sub peerport {
Subroutine peerport: not called CC=3 SCAR=24.8
Pod documented
295 0 ▶ @_ == 1 or croak 'usage: $sock->peerport()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->peerport()") 0 0 0
296 0 my($sock) = @_;
297 0 my $name = $sock->peername;
298 0 ▶ $name ? (sockaddr_in($name))[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 0 0 0
299 }
300  
301 0 ▶sub peerhost {
Subroutine peerhost: not called CC=3 SCAR=24.8
Pod documented
302 0 ▶ @_ == 1 or croak 'usage: $sock->peerhost()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->peerhost()") 0 0 0
303 0 my($sock) = @_;
304 0 my $addr = $sock->peeraddr;
305 0 ▶ $addr ? inet_ntoa($addr) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$addr ? : 0 0 0
306 }
307  
308 5 1;
309  
310 __END__
« /usr/local/lib/perl5/site_perl/5.44.0/Method/Generate/Accessor.pm ↑ Summary /usr/local/lib/perl5/5.44.0/constant.pm »