blib/lib/IO/Socket/INET.pm

filter: Statementstmt 73.4% 116 / 158 Branchbran 49.2% 66 / 134 Conditioncond 55.8% 38 / 68 MC/DCmcdc 27.5% 11 / 40 Subroutinesub 72.7% 16 / 22 Podpod 80.0% 8 / 10 totaltotal 59.0% 255 / 432 CC 90 SCAR 37.3
CC
90
Cov
61%
configure
91.1
_sock_info
25.8
sockaddr
12.0
CRAP 41.8
↑ Summary blib/lib/IO/Pipe.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 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 18 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 18 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 18 ▶use Errno;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 18 our @ISA = qw(IO::Socket);
17 18 our $VERSION = "1.55";
18  
19 18 ▶my $EINVAL = exists(&Errno::EINVAL) ? Errno::EINVAL() : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists &Errno::EINVAL ? : 18 0 18
20  
21 18 IO::Socket::INET->register_domain( AF_INET );
22  
23 18 my %socket_type = ( tcp => SOCK_STREAM,
24 udp => SOCK_DGRAM,
25 icmp => SOCK_RAW
26 );
27 18 my %proto_number;
28 18 ▶$proto_number{tcp} = Socket::IPPROTO_TCP() if defined &Socket::IPPROTO_TCP;
Branch: 1 branch
BranchTrueFalseTotal
if defined &Socket::IPPROTO_TCP 18 0 18
29 18 ▶$proto_number{udp} = Socket::IPPROTO_UDP() if defined &Socket::IPPROTO_UDP;
Branch: 1 branch
BranchTrueFalseTotal
if defined &Socket::IPPROTO_UDP 18 0 18
30 18 ▶$proto_number{icmp} = Socket::IPPROTO_ICMP() if defined &Socket::IPPROTO_ICMP;
Branch: 1 branch
BranchTrueFalseTotal
if defined &Socket::IPPROTO_ICMP 18 0 18
31 18 my %proto_name = reverse %proto_number;
32  
33 50 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
34 50 my $class = shift;
35 50 ▶ unshift(@_, "PeerAddr") if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 5 45 50
36 50 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 35 ▶sub _get_proto_number {
Subroutine _get_proto_number: called CC=4 SCAR=21.1
48 35 my $name = lc(shift);
49 35 ▶ return undef unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 35 35
50 35 ▶ return $proto_number{$name} if exists $proto_number{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $proto_number{$name} 35 0 35
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 35 ▶sub _get_proto_name {
Subroutine _get_proto_name: called CC=4 SCAR=21.1
60 35 my $num = shift;
61 35 ▶ return undef unless defined $num;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $num 0 35 35
62 35 ▶ return $proto_name{$num} if exists $proto_name{$num};
Branch: 1 branch
BranchTrueFalseTotal
if exists $proto_name{$num} 35 0 35
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 54 ▶sub _sock_info {
Subroutine _sock_info: called CC=18 SCAR=32.5
72 54 my($addr,$port,$proto) = @_;
73 54 my $origport = $port;
74 54 my @serv = ();
75  
76 54 ▶ $port = $1
Branch: 1 branch
BranchTrueFalseTotal
if defined $addr and $addr =~ s[:([\w\(\)/]+)$][] 7 47 54
Condition100%3/3
defined $addr and $addr =~ s[:([\w\(\)/]+)$][]
!ll&&!rl&&r
21267
MC/DC100%2/2
defined $addr and $addr =~ s[:([\w\(\)/]+)$][]
defined $addr $addr =~ s[:([\w\(\)/]+)$][]
Truth table100%3/3
A and B
A= defined $addrB= $addr =~ s[:([\w\(\)/]+)$][]
ABresult
0X0
100
111
77 if(defined $addr && $addr =~ s,:([\w\(\)/]+)$,,);
78  
79 54 ▶ if(defined $proto && $proto =~ /\D/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proto and $proto =~ /\D/) 22 32 54
Condition100%3/3
defined $proto and $proto =~ /\D/
!ll&&!rl&&r
211122
MC/DC100%2/2
defined $proto and $proto =~ /\D/
defined $proto $proto =~ /\D/
Truth table100%3/3
A and B
A= defined $protoB= $proto =~ /\D/
ABresult
0X0
100
111
80 22 my $num = _get_proto_number($proto);
81 22 ▶ unless (defined $num) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 22 22
82 0 $IO::Socket::errstr = $@ = "Bad protocol '$proto'";
83 0 return;
84 }
85 22 $proto = $num;
86 }
87  
88 54 ▶ if(defined $port) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $port) 11 43 54
89 11 ▶ my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
$port =~ s/\((\d+)\)$// ? : 0 11 11
90 11 my $pnum = ($port =~ m,^(\d+)$,)[0];
91  
92 11 ▶ @serv = getservbyname($port, _get_proto_name($proto) || "")
Branch: 1 branch
BranchTrueFalseTotal
if $port =~ /\D/ 0 11 11
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 11 ▶ $port = $serv[2] || $defport || $pnum;
Condition33%2/6
$serv[2] || $defport || $pnum
l!l&&r!l&&!r
0110
$serv[2] or $defport
l!l&&r!l&&!r
0011
MC/DC0%0/3
$serv[2] || $defport || $pnum
$serv[2] $defport $pnum
Truth table25%1/4
A or B || C
A= $serv[2]B= $defportC= $pnum
ABCresult
1XX1
01X1
0011
0000
96 11 ▶ unless (defined $port) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $port) 0 11 11
97 0 $IO::Socket::errstr = $@ = "Bad service '$origport'";
98 0 return;
99 }
100  
101 11 ▶ $proto = _get_proto_number($serv[3]) if @serv && !$proto;
Branch: 1 branch
BranchTrueFalseTotal
if @serv and not $proto 0 11 11
Condition33%1/3
@serv and not $proto
!ll&&!rl&&r
1100
MC/DC0%0/2
@serv and not $proto
@serv not $proto
Truth table33%1/3
A and not(B)
A= @servB= not $proto
ABresult
0X0
100
111
102 }
103  
104 54 ▶ return ($addr || undef,
Condition100%6/6
$addr || undef
l!l
3321
$port || undef
l!l
1143
$proto || undef
l!l
3321
MC/DC100%1/1
$addr || undef
$addr
MC/DC100%1/1
$port || undef
$port
MC/DC100%1/1
$proto || undef
$proto
Truth table100%2/2
A
A= $addr
Aresult
11
00
Truth table100%2/2
A
A= $port
Aresult
11
00
Truth table100%2/2
A
A= $proto
Aresult
11
00
105 $port || undef,
106 $proto || undef
107 );
108 }
109  
110 1 ▶sub _error {
Subroutine _error: called CC=3 SCAR=11.1
111 1 my $sock = shift;
112 1 my $err = shift;
113 {
114 1 local($!);
115 1 my $title = ref($sock).": ";
116 1 ▶ $IO::Socket::errstr = $@ = join("", $_[0] =~ /^$title/ ? "" : $title, @_);
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^$title/ ? : 0 1 1
117 1 ▶ $sock->close()
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $sock 1 0 1
118 if(defined fileno($sock));
119 }
120 1 $! = $err;
121 1 return undef;
122 }
123  
124 10 ▶sub _get_addr {
Subroutine _get_addr: called CC=4 SCAR=15.5
125 10 my($sock,$addr_str, $multi) = @_;
126 10 my @addr;
127 10 ▶ if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($multi and not $addr_str =~ /^\d+(?:\.\d+){3}$/) { } 0 10 10
Condition33%1/3
$multi and not $addr_str =~ /^\d+(?:\.\d+){3}$/
!ll&&!rl&&r
1000
MC/DC0%0/2
$multi and not $addr_str =~ /^\d+(?:\.\d+){3}$/
$multi not $addr_str =~ /^\d+(?:\.\d+){3}$/
Truth table33%1/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 10 my $h = inet_aton($addr_str);
131 10 ▶ push(@addr, $h) if defined $h;
Branch: 1 branch
BranchTrueFalseTotal
if defined $h 10 0 10
132 }
133 10 @addr;
134 }
135  
136 35 ▶sub configure {
Subroutine configure: called CC=42 SCAR=45.1
Pod undocumented
137 35 my($sock,$arg) = @_;
138 35 my($lport,$rport,$laddr,$raddr,$proto,$type);
139  
140  
141 $arg->{LocalAddr} = $arg->{LocalHost}
142 35 ▶ if exists $arg->{LocalHost} && !exists $arg->{LocalAddr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"} 0 35 35
Condition33%1/3
exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"}
!ll&&!rl&&r
3500
MC/DC0%0/2
exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"}
exists $arg->{"LocalHost"} not exists $arg->{"LocalAddr"}
Truth table33%1/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 35 ▶ or return _error($sock, $!, $@);
Branch: 1 branch
BranchTrueFalseTotal
($laddr, $lport, $proto) = _sock_info($arg->{"LocalAddr"}, $arg->{"LocalPort"}, $arg->{"Proto"}) or return _error($sock, $!, $@) 35 0 35
148  
149 35 ▶ $laddr = defined $laddr ? inet_aton($laddr)
Branch: 1 branch
BranchTrueFalseTotal
defined $laddr ? : 22 13 35
150 : INADDR_ANY;
151  
152 35 ▶ return _error($sock, $EINVAL, "Bad hostname '",$arg->{LocalAddr},"'")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $laddr 0 35 35
153 unless(defined $laddr);
154  
155 $arg->{PeerAddr} = $arg->{PeerHost}
156 35 ▶ if exists $arg->{PeerHost} && !exists $arg->{PeerAddr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"} 1 34 35
Condition66%2/3
exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"}
!ll&&!rl&&r
3401
MC/DC50%1/2
exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"}
exists $arg->{"PeerHost"} not exists $arg->{"PeerAddr"}
Truth table66%2/3
A and not(B)
A= exists $arg->{"PeerHost"}B= not exists $arg->{"PeerAddr"}
ABresult
0X0
100
111
157  
158 35 ▶ unless(exists $arg->{Listen}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $arg->{"Listen"}) 19 16 35
159 ($raddr,$rport,$proto) = _sock_info($arg->{PeerAddr},
160 $arg->{PeerPort},
161 19 ▶ $proto)
Branch: 1 branch
BranchTrueFalseTotal
($raddr, $rport, $proto) = _sock_info($arg->{"PeerAddr"}, $arg->{"PeerPort"}, $proto) or return _error($sock, $!, $@) 19 0 19
162 or return _error($sock, $!, $@);
163 }
164  
165 35 ▶ $proto ||= _get_proto_number('tcp');
Condition66%2/3
$proto ||= _get_proto_number("tcp")
l!l&&r!l&&!r
22130
MC/DC0%0/2
$proto ||= _get_proto_number("tcp")
$proto _get_proto_number("tcp")
Truth table66%2/3
A ||= B
A= $protoB= _get_proto_number("tcp")
ABresult
1X1
011
000
166  
167 35 ▶ $type = $arg->{Type} || $socket_type{lc _get_proto_name($proto)};
Condition33%1/3
$arg->{'Type'} || $socket_type{lc _get_proto_name($proto)}
l!l&&r!l&&!r
0350
MC/DC0%0/2
$arg->{'Type'} || $socket_type{lc _get_proto_name($proto)}
$arg->{'Type'} $socket_type{lc _get_proto_name($proto)}
Truth table33%1/3
A || B
A= $arg->{'Type'}B= $socket_type{lc _get_proto_name($proto)}
ABresult
1X1
011
000
168  
169 35 my @raddr = ();
170  
171 35 ▶ if(defined $raddr) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $raddr) 11 24 35
172 11 @raddr = $sock->_get_addr($raddr, $arg->{MultiHomed});
173 11 ▶ return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'")
Branch: 1 branch
BranchTrueFalseTotal
unless @raddr 0 11 11
174 unless @raddr;
175 }
176  
177 35 while(1) {
178  
179 37 ▶ $sock->socket(AF_INET, $type, $proto) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->socket(2, $type, $proto) or return _error($sock, $!, "$!") 37 0 37
180 return _error($sock, $!, "$!");
181  
182 37 ▶ if (defined $arg->{Blocking}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg->{"Blocking"}) 1 36 37
183 defined $sock->blocking($arg->{Blocking})
184 1 ▶ or return _error($sock, $!, "$!");
Branch: 1 branch
BranchTrueFalseTotal
defined $sock->blocking($arg->{"Blocking"}) or return _error($sock, $!, "$!") 1 0 1
185 }
186  
187 37 ▶ if ($arg->{Reuse} || $arg->{ReuseAddr}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"Reuse"} or $arg->{"ReuseAddr"}) 0 37 37
Condition33%1/3
$arg->{"Reuse"} or $arg->{"ReuseAddr"}
l!l&&r!l&&!r
0037
MC/DC0%0/2
$arg->{"Reuse"} or $arg->{"ReuseAddr"}
$arg->{"Reuse"} $arg->{"ReuseAddr"}
Truth table33%1/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 37 ▶ if ($arg->{ReusePort}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"ReusePort"}) 0 37 37
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 37 ▶ if ($arg->{Broadcast}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"Broadcast"}) 0 37 37
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 37 ▶ 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"}) 23 14 37
Condition83%5/6
$lport or $laddr ne "\0\0\0\0" or exists $arg->{"Listen"}
l!l&&r!l&&!r
22114
$lport or $laddr ne "\0\0\0\0"
l!l&&r!l&&!r
02215
MC/DC66%2/3
$lport or $laddr ne "\0\0\0\0" or exists $arg->{"Listen"}
$lport $laddr ne "\0\0\0\0" exists $arg->{"Listen"}
Truth table75%3/4
A or B or C
A= $lportB= $laddr ne "\0\0\0\0"C= exists $arg->{"Listen"}
ABCresult
1XX1
01X1
0011
0000
203 23 ▶ $sock->bind($lport || 0, $laddr) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->bind($lport || 0, $laddr) or return _error($sock, $!, "$!") 23 0 23
Condition50%1/2
$lport || 0
l!l
023
MC/DC0%0/1
$lport || 0
$lport
Truth table50%1/2
A
A= $lport
Aresult
11
00
204 return _error($sock, $!, "$!");
205 }
206  
207 37 ▶ if(exists $arg->{Listen}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg->{"Listen"}) 16 21 37
208 16 ▶ $sock->listen($arg->{Listen} || 5) or
Branch: 1 branch
BranchTrueFalseTotal
$sock->listen($arg->{"Listen"} || 5) or return _error($sock, $!, "$!") 16 0 16
Condition100%2/2
$arg->{'Listen'} || 5
l!l
124
MC/DC100%1/1
$arg->{'Listen'} || 5
$arg->{'Listen'}
Truth table100%2/2
A
A= $arg->{'Listen'}
Aresult
11
00
209 return _error($sock, $!, "$!");
210 16 last;
211 }
212  
213 # don't try to connect unless we're given a PeerAddr
214 21 ▶ last unless exists($arg->{PeerAddr});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $arg->{"PeerAddr"} 8 13 21
215
216 13 $raddr = shift @raddr;
217  
218 13 ▶ return _error($sock, $EINVAL, 'Cannot determine remote port')
Branch: 1 branch
BranchTrueFalseTotal
unless $rport or $type == 2 or $type == 3 0 13 13
Condition33%2/6
$rport or $type == 2 or $type == 3
l!l&&r!l&&!r
1300
$rport or $type == 2
l!l&&r!l&&!r
1300
MC/DC0%0/3
$rport or $type == 2 or $type == 3
$rport $type == 2 $type == 3
Truth table25%1/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 13 ▶ unless($type == SOCK_STREAM || defined $raddr);
Branch: 1 branch
BranchTrueFalseTotal
unless $type == 1 or defined $raddr 0 13 13
Condition66%2/3
$type == 1 or defined $raddr
l!l&&r!l&&!r
1210
MC/DC0%0/2
$type == 1 or defined $raddr
$type == 1 defined $raddr
Truth table66%2/3
A or B
A= $type == 1B= defined $raddr
ABresult
1X1
011
000
223  
224 13 ▶ return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $raddr 0 13 13
225 unless defined $raddr;
226  
227 # my $timeout = ${*$sock}{'io_socket_timeout'};
228 # my $before = time() if $timeout;
229  
230 13 undef $@;
231 13 ▶ if ($sock->connect(pack_sockaddr_in($rport, $raddr))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sock->connect(pack_sockaddr_in($rport, $raddr))) 10 3 13
232 # ${*$sock}{'io_socket_timeout'} = $timeout;
233 10 return $sock;
234 }
235  
236 3 ▶ return _error($sock, $!, $@ || "Timeout")
Branch: 1 branch
BranchTrueFalseTotal
unless @raddr 1 2 3
Condition50%1/2
$@ || 'Timeout'
l!l
10
MC/DC0%0/1
$@ || 'Timeout'
$@
Truth table50%1/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 24 $sock;
250 }
251  
252 12 ▶sub connect {
Subroutine connect: called CC=4 SCAR=16.1
Pod undocumented
253 12 ▶ @_ == 2 || @_ == 3 or
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or croak("usage: \$sock->connect(NAME) or \$sock->connect(PORT, ADDR)") 12 0 12
Condition33%1/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
1200
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table33%1/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
254 croak 'usage: $sock->connect(NAME) or $sock->connect(PORT, ADDR)';
255 12 my $sock = shift;
256 12 ▶ return $sock->SUPER::connect(@_ == 1 ? shift : pack_sockaddr_in(@_));
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 12 0 12
257 }
258  
259 23 ▶sub bind {
Subroutine bind: called CC=4 SCAR=16.1
Pod documented
260 23 ▶ @_ == 2 || @_ == 3 or
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or croak("usage: \$sock->bind(NAME) or \$sock->bind(PORT, ADDR)") 23 0 23
Condition33%1/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
0230
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table33%1/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
261 croak 'usage: $sock->bind(NAME) or $sock->bind(PORT, ADDR)';
262 23 my $sock = shift;
263 23 ▶ return $sock->SUPER::bind(@_ == 1 ? shift : pack_sockaddr_in(@_))
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 23 23
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 18 ▶sub sockport {
Subroutine sockport: called CC=3 SCAR=11.4
Pod documented
274 18 ▶ @_ == 1 or croak 'usage: $sock->sockport()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$sock->sockport()") 18 0 18
275 18 my($sock) = @_;
276 18 my $name = $sock->sockname;
277 18 ▶ $name ? (sockaddr_in($name))[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 18 0 18
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 18 1;
309  
310 __END__
↑ Summary blib/lib/IO/Pipe.pm »