blib/lib/Net/Socket/NonBlock.pm

filter: Statementstmt 54.4% 285 / 523 Branchbran 34.8% 87 / 250 Conditioncond 15.7% 37 / 235 MC/DCmcdc 3.1% 4 / 128 Subroutinesub 59.3% 35 / 59 Podpod 100% 15 / 15 totaltotal 38.2% 463 / 1210 CC 206 SCAR 37.4
CC
206
Cov
41%
Read
182.0
Properties
156.0
Recv
90.0
CRAP 41.9
↑ Summary
1 package Net::Socket::NonBlock;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #$^W++;
6  
7 1 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 require Exporter;
10  
11 1 @ISA = qw(Exporter);
12  
13 1 %EXPORT_TAGS = ();
14  
15 1 foreach (keys(%EXPORT_TAGS))
16 0 { push(@{$EXPORT_TAGS{'all'}}, @{$EXPORT_TAGS{$_}}); };
17  
18 $EXPORT_TAGS{'all'}
19 0 ▶ and @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
Branch: 1 branch
BranchTrueFalseTotal
$Net::Socket::NonBlock::EXPORT_TAGS{"all"} and @Net::Socket::NonBlock::EXPORT_OK = @{$Net::Socket::NonBlock::EXPORT_TAGS{"all"};} 0 1 1
20  
21 1 @EXPORT = qw(
22 );
23  
24 1 $VERSION = '0.15';
25  
26 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use IO::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 # Preloaded methods go here.
31  
32 my $ThrowMsg = sub($$$)
33 8 ▶ {
Subroutine __ANON__: called CC=4 SCAR=14.0
34 8 my ($Nest, $CarpCond, $Msg) = @_;
35  
36 8 ▶ $CarpCond
Branch: 1 branch
BranchTrueFalseTotal
$CarpCond and Carp::carp($Msg) 0 8 8
37 and Carp::carp $Msg;
38  
39 ($Nest && $Nest->{'ErrArray'})
40 8 ▶ and push(@{$Nest->{'ErrArray'}}, $Msg);
Branch: 1 branch
BranchTrueFalseTotal
$Nest and $Nest->{"ErrArray"} and push @{$$Nest{"ErrArray"};}, $Msg 3 5 8
Condition66%2/3
$Nest and $Nest->{"ErrArray"}
!ll&&!rl&&r
503
MC/DC50%1/2
$Nest and $Nest->{"ErrArray"}
$Nest $Nest->{"ErrArray"}
Truth table66%2/3
A and B
A= $NestB= $Nest->{"ErrArray"}
ABresult
0X0
100
111
41  
42 8 return 1;
43 1 };
44  
45 sub newNest
46 0 ▶ { shift; return Net::Socket::NonBlock::Nest->new(@_); };
Subroutine newNest: not called CC=1 SCAR=6.9
Pod documented
47 sub new
48 1 ▶ { shift; return Net::Socket::NonBlock::Nest->new(@_); };
Subroutine new: called CC=1 SCAR=0.0
Pod documented
49  
50 my $Die = sub($)
51 0 ▶ { Carp::confess $_[0]; };
Subroutine __ANON__: not called CC=1 SCAR=1.2
52  
53 my $BuffSize = sub($$)
54 33 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.2
55 33 my ($SRec, $BuffName) = @_;
56 ($SRec->{$BuffName})
57 0 ▶ or &{$Die}("$SRec: buffer '$BuffName' does not exists");
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{$BuffName} or &{$Die;}("${SRec}: buffer '${BuffName}' does not exists") 33 0 33
58  
59 33 my $Result = 0;
60 33 foreach (@{$SRec->{$BuffName}})
61 33 { $Result += length($_->{'Data'}); };
62  
63 33 return $Result;
64 1 };
65  
66 my $BuffEmpty = sub($$)
67 0 ▶ {
Subroutine __ANON__: not called CC=3 SCAR=24.8
68 0 my ($SRec, $BuffName) = @_;
69 ($SRec->{$BuffName})
70 0 ▶ or &{$Die}("$SRec: buffer '$BuffName' does not exists");
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{$BuffName} or &{$Die;}("${SRec}: buffer '${BuffName}' does not exists") 0 0 0
71  
72 0 ▶ if ($SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"TCP"}) 0 0 0
73 0 { return (!length($SRec->{$BuffName}->[0]->{'Data'})); };
74  
75 0 return (!scalar(@{$SRec->{$BuffName}}));
76 1 };
77  
78 my $SockAvail = sub($)
79 7 ▶ {
Subroutine __ANON__: called CC=4 SCAR=20.4
80 7 my ($SRec) = @_;
81  
82 0 ▶ ($SRec->{'Close'} || ($SRec->{'EOF'} && &{$BuffEmpty}($SRec, 'Input')))
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Close"} or $SRec->{"EOF"} and &{$BuffEmpty;}($SRec, "Input") or return $SRec 0 7 7
Condition33%2/6
$SRec->{"Close"} or $SRec->{"EOF"} and &{$BuffEmpty;}($SRec, "Input")
l!l&&r!l&&!r
007
$SRec->{"EOF"} and &{$BuffEmpty;}($SRec, "Input")
!ll&&!rl&&r
700
MC/DC0%0/3
$SRec->{"Close"} or $SRec->{"EOF"} and &{$BuffEmpty;}($SRec, "Input")
$SRec->{"Close"} $SRec->{"EOF"} &{$BuffEmpty;}($SRec, "Input")
Truth table25%1/4
A or B and C
A= $SRec->{"Close"}B= $SRec->{"EOF"}C= &{$BuffEmpty;}($SRec, "Input")
ABCresult
1XX1
0111
00X0
0100
83 or return $SRec;
84
85 0 $@ = $SRec->{'Error'};
86 0 return;
87 1 };
88  
89 my $CloseSR = sub($)
90 3 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
91 3 my ($SRec) = @_;
92  
93 $SRec->{'Socket'}
94 3 ▶ and $SRec->{'Socket'}->close();
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Socket"} and $SRec->{"Socket"}->close 3 0 3
95 3 delete($SRec->{'Socket'});
96  
97 $SRec->{'Parent'}
98 3 ▶ and $SRec->{'Parent'}{'Clients'}--;
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Parent"} and --$SRec->{"Parent"}{"Clients"} 1 2 3
99 3 delete($SRec->{'Parent'});
100  
101 3 return 1;
102 1 };
103  
104 my $Close = sub($$)
105 3 ▶ {
Subroutine __ANON__: called CC=2 SCAR=7.0
106 3 my ($Nest, $SRec) = @_;
107  
108 $SRec->{'Socket'}
109 3 ▶ and $Nest->{'Select'}->remove($SRec->{'Socket'});
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Socket"} and $Nest->{"Select"}->remove($SRec->{"Socket"}) 3 0 3
110 3 delete($Nest->{'S2Rec'}{$SRec->{'Socket'}});
111 3 delete($Nest->{'Pool'}{$SRec});
112 3 &{$CloseSR}($SRec);
113  
114 3 return 1;
115 1 };
116  
117 my $EOF = sub($$$)
118 0 ▶ {
Subroutine __ANON__: not called CC=3 SCAR=24.8
119 0 my ($Nest, $SRec, $Error) = @_;
120 0 $SRec->{'EOF'}++;
121 0 ▶ if (length($Error))
Branch: 1 branch
BranchTrueFalseTotal
if (length $Error) 0 0 0
122 {
123 0 $SRec->{'Error'} = $Error;
124 0 $@ = $Error;
125 0 ▶ &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: $Error");
Condition0%0/3
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
126 };
127 0 $Nest->{'Select'}->remove($SRec->{'Socket'});
128 0 return;
129 1 };
130  
131 sub Gets
132 4 ▶ {
Subroutine Gets: called CC=15 SCAR=33.8
Pod documented
133 4 my ($SRec, $BufLen) = @_;
134  
135 4 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 4 0 4
136 or return;
137  
138 ($BufLen && $BufLen > 0 && $BufLen < 32767 && $BufLen < $SRec->{'BuffSize'})
139 4 ▶ or $BufLen = ($SRec->{'BuffSize'} < 32767) ? $SRec->{'BuffSize'} : 32766;
Branch: 2 branches
BranchTrueFalseTotal
$BufLen and $BufLen > 0 and $BufLen < 32767 and $BufLen < $SRec->{"BuffSize"} or $BufLen = $SRec->{"BuffSize"} < 32767 ? $SRec->{"BuffSize"} : 32766 0 4 4
$SRec->{'BuffSize'} < 32767 ? : 4 0 4
Condition33%3/9
$BufLen and $BufLen > 0 and $BufLen < 32767 and $BufLen < $SRec->{"BuffSize"}
!ll&&!rl&&r
400
$BufLen and $BufLen > 0 and $BufLen < 32767
!ll&&!rl&&r
400
$BufLen and $BufLen > 0
!ll&&!rl&&r
400
MC/DC0%0/4
$BufLen and $BufLen > 0 and $BufLen < 32767 and $BufLen < $SRec->{"BuffSize"}
$BufLen $BufLen > 0 $BufLen < 32767 $BufLen < $SRec->{"BuffSize"}
Truth table20%1/5
A and B and C and D
A= $BufLenB= $BufLen > 0C= $BufLen < 32767D= $BufLen < $SRec->{"BuffSize"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
140  
141 4 $BufLen--;
142  
143 4 my @Result = ('', '', '');
144  
145 4 ▶ if ($SRec->{'Input'}->[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"Input"}[0]) 4 0 4
146 {
147 4 ▶ if (($SRec->{'Input'}->[0]->{'Data'} =~ s/\A(.{0,$BufLen}\n)//m) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{$BufLen}.)//m or $SRec->{"EOF"} and $SRec->{"Input"}[0]{"Data"} =~ s/\A([.\n]+)//m) 2 2 4
Condition55%5/9
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{$BufLen}.)//m or $SRec->{"EOF"} and $SRec->{"Input"}[0]{"Data"} =~ s/\A([.\n]+)//m
l!l&&r!l&&!r
202
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{$BufLen}.)//m
l!l&&r!l&&!r
202
$SRec->{"EOF"} and $SRec->{"Input"}[0]{"Data"} =~ s/\A([.\n]+)//m
!ll&&!rl&&r
200
MC/DC25%1/4
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{$BufLen}.)//m or $SRec->{"EOF"} and $SRec->{"Input"}[0]{"Data"} =~ s/\A([.\n]+)//m
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{$BufLen}.)//m $SRec->{"EOF"} $SRec->{"Input"}[0]{"Data"} =~ s/\A([.\n]+)//m
Truth table40%2/5
A or B or C and D
A= $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//mB= $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{$BufLen}.)//mC= $SRec->{"EOF"}D= $SRec->{"Input"}[0]{"Data"} =~ s/\A([.\n]+)//m
ABCDresult
1XXX1
01XX1
00111
000X0
00100
148 ($SRec->{'Input'}->[0]->{'Data'} =~ s/\A(.{$BufLen}.)//m ) ||
149 ($SRec->{'EOF'} && ($SRec->{'Input'}->[0]->{'Data'} =~ s/\A([.\n]+)//m)))
150 {
151 2 $SRec->{'PeerAddr'} = $SRec->{'Input'}->[0]->{'PeerAddr'};
152 2 $SRec->{'PeerPort'} = $SRec->{'Input'}->[0]->{'PeerPort'};
153 2 @Result = ($1, $SRec->{'PeerAddr'}, $SRec->{'PeerPort'});
154 };
155  
156 4 ▶ if (!$SRec->{'TCP'} &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}) 0 4 4
Condition33%1/3
$SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}
l!l&&r!l&&!r
400
MC/DC0%0/2
$SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}
$SRec->{"TCP"} length $SRec->{"Input"}[0]{"Data"}
Truth table33%1/3
A or B
A= $SRec->{"TCP"}B= length $SRec->{"Input"}[0]{"Data"}
ABresult
1X1
011
000
157 !length($SRec->{'Input'}->[0]->{'Data'}))
158 {
159 0 shift(@{$SRec->{'Input'}});
160 };
161 };
162  
163 4 ▶ return wantarray ? @Result : $Result[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 4 4
164 };
165  
166 sub Read
167 0 ▶ {
Subroutine Read: not called CC=13 SCAR=52.0
Pod documented
168 0 my ($SRec, $BufLen) = @_;
169  
170 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
171 or return;
172  
173 ($BufLen && $BufLen > 0 && $BufLen < 32767 && $BufLen < $SRec->{'BuffSize'})
174 0 ▶ or $BufLen = ($SRec->{'BuffSize'} < 32767) ? $SRec->{'BuffSize'} : 32766;
Branch: 2 branches
BranchTrueFalseTotal
$BufLen and $BufLen > 0 and $BufLen < 32767 and $BufLen < $SRec->{"BuffSize"} or $BufLen = $SRec->{"BuffSize"} < 32767 ? $SRec->{"BuffSize"} : 32766 0 0 0
$SRec->{'BuffSize'} < 32767 ? : 0 0 0
Condition0%0/9
$BufLen and $BufLen > 0 and $BufLen < 32767 and $BufLen < $SRec->{"BuffSize"}
!ll&&!rl&&r
000
$BufLen and $BufLen > 0 and $BufLen < 32767
!ll&&!rl&&r
000
$BufLen and $BufLen > 0
!ll&&!rl&&r
000
MC/DC0%0/4
$BufLen and $BufLen > 0 and $BufLen < 32767 and $BufLen < $SRec->{"BuffSize"}
$BufLen $BufLen > 0 $BufLen < 32767 $BufLen < $SRec->{"BuffSize"}
Truth table0%0/5
A and B and C and D
A= $BufLenB= $BufLen > 0C= $BufLen < 32767D= $BufLen < $SRec->{"BuffSize"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
175  
176 0 $BufLen--;
177  
178 0 my @Result = ('', '', '');
179  
180 0 ▶ if ($SRec->{'Input'}->[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"Input"}[0]) 0 0 0
181 {
182 0 ▶ if (($SRec->{'Input'}->[0]->{'Data'} =~ s/\A(.{0,$BufLen}\n)//m) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}.)//m) 0 0 0
Condition0%0/3
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}.)//m
l!l&&r!l&&!r
000
MC/DC0%0/2
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m or $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}.)//m
$SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//m $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}.)//m
Truth table0%0/3
A or B
A= $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}\n)//mB= $SRec->{"Input"}[0]{"Data"} =~ s/\A(.{0,$BufLen}.)//m
ABresult
1X1
011
000
183 ($SRec->{'Input'}->[0]->{'Data'} =~ s/\A(.{0,$BufLen}.)//m ))
184 {
185 0 $SRec->{'PeerAddr'} = $SRec->{'Input'}->[0]->{'PeerAddr'};
186 0 $SRec->{'PeerPort'} = $SRec->{'Input'}->[0]->{'PeerPort'};
187 0 @Result = ($1, $SRec->{'PeerAddr'}, $SRec->{'PeerPort'});
188 };
189  
190 0 ▶ if (!$SRec->{'TCP'} &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}) 0 0 0
Condition0%0/3
$SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}
$SRec->{"TCP"} length $SRec->{"Input"}[0]{"Data"}
Truth table0%0/3
A or B
A= $SRec->{"TCP"}B= length $SRec->{"Input"}[0]{"Data"}
ABresult
1X1
011
000
191 !length($SRec->{'Input'}->[0]->{'Data'}))
192 {
193 0 shift(@{$SRec->{'Input'}});
194 };
195 };
196  
197 0 ▶ return wantarray ? @Result : $Result[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
198 };
199  
200 sub Recv
201 0 ▶ {
Subroutine Recv: not called CC=9 SCAR=45.0
Pod documented
202 0 my ($SRec, $BufLen) = @_;
203  
204 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
205 or return;
206  
207 ($BufLen && $BufLen > 0 && $BufLen < $SRec->{'BuffSize'})
208 0 ▶ or $BufLen = $SRec->{'BuffSize'};
Branch: 1 branch
BranchTrueFalseTotal
$BufLen and $BufLen > 0 and $BufLen < $SRec->{"BuffSize"} or $BufLen = $SRec->{"BuffSize"} 0 0 0
Condition0%0/6
$BufLen and $BufLen > 0 and $BufLen < $SRec->{"BuffSize"}
!ll&&!rl&&r
000
$BufLen and $BufLen > 0
!ll&&!rl&&r
000
MC/DC0%0/3
$BufLen and $BufLen > 0 and $BufLen < $SRec->{"BuffSize"}
$BufLen $BufLen > 0 $BufLen < $SRec->{"BuffSize"}
Truth table0%0/4
A and B and C
A= $BufLenB= $BufLen > 0C= $BufLen < $SRec->{"BuffSize"}
ABCresult
0XX0
10X0
1100
1111
209
210 0 my @Result = ('', '', '');
211  
212 0 ▶ if ($SRec->{'Input'}->[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"Input"}[0]) 0 0 0
213 {
214 0 $SRec->{'PeerAddr'} = $SRec->{'Input'}->[0]->{'PeerAddr'};
215 0 $SRec->{'PeerPort'} = $SRec->{'Input'}->[0]->{'PeerPort'};
216 @Result = (substr($SRec->{'Input'}->[0]->{'Data'}, 0, $BufLen),
217 0 $SRec->{'PeerAddr'}, $SRec->{'PeerPort'});
218 0 substr($SRec->{'Input'}->[0]->{'Data'}, 0, $BufLen) = '';
219  
220 0 ▶ if (!$SRec->{'TCP'} &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}) 0 0 0
Condition0%0/3
$SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$SRec->{"TCP"} or length $SRec->{"Input"}[0]{"Data"}
$SRec->{"TCP"} length $SRec->{"Input"}[0]{"Data"}
Truth table0%0/3
A or B
A= $SRec->{"TCP"}B= length $SRec->{"Input"}[0]{"Data"}
ABresult
1X1
011
000
221 !length($SRec->{'Input'}->[0]->{'Data'}))
222 {
223 0 shift(@{$SRec->{'Input'}});
224 };
225 };
226  
227 0 ▶ return wantarray ? @Result : $Result[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
228 };
229  
230 sub Puts
231 2 ▶ {
Subroutine Puts: called CC=11 SCAR=39.9
Pod documented
232 2 my ($SRec, $Data, $PeerAddr, $PeerPort) = @_;
233  
234 2 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 2 0 2
235 or return;
236  
237 2 ▶ if ($SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{'TCP'}) { } 2 0 2
238 {
239 defined($SRec->{'Output'}->[0]->{'Data'})
240 2 ▶ or $SRec->{'Output'}->[0]->{'Data'} = '';
Branch: 1 branch
BranchTrueFalseTotal
defined $SRec->{"Output"}[0]{"Data"} or $SRec->{"Output"}[0]{"Data"} = "" 2 0 2
241 0 ▶ $SRec->{'Output'}->[0]->{'Data'} .= ((ref($Data) eq 'ARRAY') ? join('', @{$Data}) : $Data);
Branch: 1 branch
BranchTrueFalseTotal
ref $Data eq 'ARRAY' ? : 0 2 2
242 2 $SRec->{'Output'}->[0]->{'Dest'} = undef;
243 }
244 else
245 {
246 defined($PeerAddr)
247 0 ▶ or $PeerAddr = $SRec->{'PeerAddr'};
Branch: 1 branch
BranchTrueFalseTotal
defined $PeerAddr or $PeerAddr = $SRec->{"PeerAddr"} 0 0 0
248 defined($PeerPort)
249 0 ▶ or $PeerPort = $SRec->{'PeerPort'};
Branch: 1 branch
BranchTrueFalseTotal
defined $PeerPort or $PeerPort = $SRec->{"PeerPort"} 0 0 0
250
251 0 my $PeerIP = inet_aton($PeerAddr);
252 0 my $Dest = pack_sockaddr_in($PeerPort, $PeerIP);
253 0 ▶ (defined($PeerIP) && defined($Dest))
Branch: 1 branch
BranchTrueFalseTotal
defined $PeerIP and defined $Dest or $@ = "${SRec}: invalid destination address '${PeerAddr}:${PeerPort}'" and return 0 0 0
Condition0%0/8
defined $PeerIP && defined $Dest || ($@ = "${SRec}: invalid destination address '${PeerAddr}:${PeerPort}'") && (return)
l!l&&r!l&&!r
000
defined $PeerIP and defined $Dest
!ll&&!rl&&r
000
$@ = "${SRec}: invalid destination address '${PeerAddr}:${PeerPort}'" and return
!ll
00
MC/DC0%0/3
defined $PeerIP && defined $Dest || ($@ = "${SRec}: invalid destination address '${PeerAddr}:${PeerPort}'") && (return)
defined $PeerIP defined $Dest $@ = "${SRec}: invalid destination address '${PeerAddr}:${PeerPort}'"
Truth table0%0/5
A and B || C
A= defined $PeerIPB= defined $DestC= $@ = "${SRec}: invalid destination address '${PeerAddr}:${PeerPort}'"
ABCresult
11X1
0X11
1011
0X00
1000
254 or $@ = "$SRec: invalid destination address '$PeerAddr:$PeerPort'"
255 and return;
256 0 ▶ push(@{$SRec->{'Output'}}, {'Data' => ((ref($Data) eq 'ARRAY') ? join('', @{$Data}) : $Data), 'Dest' => $Dest});
Branch: 1 branch
BranchTrueFalseTotal
ref $Data eq 'ARRAY' ? : 0 0 0
257 };
258 2 return 1;
259 };
260  
261 sub Send
262 0 ▶ { return Puts(@_); };
Subroutine Send: not called CC=1 SCAR=6.9
Pod documented
263  
264 sub PeerAddr
265 0 ▶ {
Subroutine PeerAddr: not called CC=2 SCAR=17.9
Pod documented
266 0 my ($SRec) = @_;
267  
268 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
269 or return;
270 0 return $SRec->{'PeerAddr'};
271 };
272  
273 sub PeerPort
274 0 ▶ {
Subroutine PeerPort: not called CC=2 SCAR=17.9
Pod documented
275 0 my ($SRec) = @_;
276  
277 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
278 or return;
279
280 0 return $SRec->{'PeerPort'};
281 };
282  
283 sub LocalAddr
284 0 ▶ {
Subroutine LocalAddr: not called CC=2 SCAR=17.9
Pod documented
285 0 my ($SRec) = @_;
286  
287 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
288 or return;
289
290 0 return $SRec->{'LocalAddr'};
291 };
292  
293 sub LocalPort
294 1 ▶ {
Subroutine LocalPort: called CC=2 SCAR=7.0
Pod documented
295 1 my ($SRec) = @_;
296  
297 1 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 1 0 1
298 or return;
299
300 1 return $SRec->{'LocalPort'};
301 };
302  
303 sub Handle
304 0 ▶ {
Subroutine Handle: not called CC=2 SCAR=17.9
Pod documented
305 0 my ($SRec) = @_;
306  
307 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
308 or return;
309
310 0 return $SRec->{'Socket'};
311 };
312  
313 sub Properties
314 0 ▶ {
Subroutine Properties: not called CC=12 SCAR=50.5
Pod documented
315 0 my ($SRec, %Params) = @_;
316  
317 0 ▶ &{$SockAvail}($SRec)
Branch: 1 branch
BranchTrueFalseTotal
&{$SockAvail;}($SRec) or return 0 0 0
318 or return;
319  
320 0 my %Result = ();
321  
322 0 $Result{'Handle'} = $SRec->{'Socket'};
323  
324 0 my $Key = undef;
325 0 foreach $Key ('Socket', 'SilenceT', 'BuffSize', 'MaxClients',
326 'ClientsST', 'Clients', 'Parent',
327 'BytesOut', 'CTime', 'ATime', 'Proto',
328 'BytesIn', 'Accept', 'PeerAddr', 'PeerPort',
329 'LocalAddr', 'LocalPort', 'Error', 'DiscEmpty')
330 {
331 defined($SRec->{$Key})
332 0 ▶ and $Result{$Key} = $SRec->{$Key};
Branch: 1 branch
BranchTrueFalseTotal
defined $SRec->{$Key} and $Result{$Key} = $SRec->{$Key} 0 0 0
333 };
334  
335 0 foreach $Key ('Input', 'Output')
336 0 { $Result{$Key} = &{$BuffSize}($SRec, $Key); };
337  
338 0 ▶ $Result{'Broadcast'} = ($SRec->{'Socket'}->sockopt(SO_BROADCAST) ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{'Socket'}->sockopt(6) ? : 0 0 0
339  
340 0 foreach $Key ('SilenceT', 'BuffSize', 'MaxClients', 'ClientsST', 'ATime', 'Accept', 'DiscEmpty')
341 {
342 (defined($Params{$Key}) && defined($SRec->{$Key}))
343 0 ▶ and $SRec->{$Key} = $Params{$Key};
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{$Key} and defined $SRec->{$Key} and $SRec->{$Key} = $Params{$Key} 0 0 0
Condition0%0/3
defined $Params{$Key} and defined $SRec->{$Key}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Params{$Key} and defined $SRec->{$Key}
defined $Params{$Key} defined $SRec->{$Key}
Truth table0%0/3
A and B
A= defined $Params{$Key}B= defined $SRec->{$Key}
ABresult
0X0
100
111
344 };
345  
346 defined($Params{'Broadcast'})
347 0 ▶ and $SRec->{'Socket'}->sockopt(SO_BROADCAST, ($Params{'Broadcast'} ? 1 : 0));
Branch: 2 branches
BranchTrueFalseTotal
defined $Params{"Broadcast"} and $SRec->{"Socket"}->sockopt(6, $Params{"Broadcast"} ? 1 : 0) 0 0 0
$Params{'Broadcast'} ? : 0 0 0
348
349 0 ▶ return wantarray ? %Result : \%Result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
350 };
351  
352 sub Close
353 3 ▶ {
Subroutine Close: called CC=3 SCAR=11.8
Pod documented
354 3 my ($SRec, $Flush, $Timeout) = @_;
355  
356 3 $SRec->{'Close'}++;
357 3 $SRec->{'Flush'} = $Flush;
358 ($Flush && $Timeout)
359 3 ▶ and $SRec->{'CloseAt'} = time() + $Timeout;
Branch: 1 branch
BranchTrueFalseTotal
$Flush and $Timeout and $SRec->{"CloseAt"} = time + $Timeout 0 3 3
Condition33%1/3
$Flush and $Timeout
!ll&&!rl&&r
300
MC/DC0%0/2
$Flush and $Timeout
$Flush $Timeout
Truth table33%1/3
A and B
A= $FlushB= $Timeout
ABresult
0X0
100
111
360 3 return;
361 };
362  
363 sub close
364 0 ▶ { Net::Socket::NonBlock::Close(@_); };
Subroutine close: not called CC=1 SCAR=6.9
Pod documented
365  
366 #################################################################################
367 #################################################################################
368 #################################################################################
369 #################################################################################
370  
371 package Net::Socket::NonBlock::Nest;
372  
373 1 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
374 1 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
375  
376 sub new($%)
377 1 ▶ {
Subroutine new: called CC=7 SCAR=20.6
378 1 my ($class, %Params) = @_;
379  
380 1 my $Nest = {};
381  
382 1 ▶ $Nest->{'Select'} = IO::Select->new()
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Select"} = "IO::Select"->new or return 1 0 1
383 or return;
384 1 $Nest->{'Pool'} = {};
385 1 ▶ $Nest->{'SelectT'} = (defined($Params{'SelectT'}) ? $Params{'SelectT'} : 0.05);
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{'SelectT'} ? : 0 1 1
386 1 ▶ $Nest->{'SilenceT'} = (defined($Params{'SilenceT'}) ? $Params{'SilenceT'} : 0);
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{'SilenceT'} ? : 1 0 1
387 1 ▶ $Nest->{'BuffSize'} = (defined($Params{'BuffSize'}) ? $Params{'BuffSize'} : POSIX::BUFSIZ);
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{'BuffSize'} ? : 0 1 1
388 1 ▶ $Nest->{'MaxClients'} = (defined($Params{'MaxClients'}) ? $Params{'MaxClients'} : 9999999999);
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{'MaxClients'} ? : 0 1 1
389 1 ▶ $Nest->{'debug'} = (defined($Params{'debug'}) ? $Params{'debug'} : 0);
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{'debug'} ? : 1 0 1
390 1 $Nest->{'class'} = $class;
391 1 return bless $Nest => $class;
392 };
393  
394 sub newNest
395 0 ▶ { shift; return Net::Socket::NonBlock::Nest->new(@_); };
Subroutine newNest: not called CC=1 SCAR=6.9
396  
397 sub Properties
398 2 ▶ {
Subroutine Properties: called CC=12 SCAR=38.2
399 2 ▶ if (!(scalar(@_) & 1) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not scalar @_ & 1 and $_[1] =~ /\ANet\:\:Socket\:\:NonBlock\=HASH\(\w+\)\Z/iso) 0 2 2
Condition33%1/3
not scalar @_ & 1 and $_[1] =~ /\ANet\:\:Socket\:\:NonBlock\=HASH\(\w+\)\Z/iso
!ll&&!rl&&r
200
MC/DC0%0/2
not scalar @_ & 1 and $_[1] =~ /\ANet\:\:Socket\:\:NonBlock\=HASH\(\w+\)\Z/iso
not scalar @_ & 1 $_[1] =~ /\ANet\:\:Socket\:\:NonBlock\=HASH\(\w+\)\Z/iso
Truth table33%1/3
not(A) and B
A= not scalar @_ & 1B= $_[1] =~ /\ANet\:\:Socket\:\:NonBlock\=HASH\(\w+\)\Z/iso
ABresult
0X0
100
111
400 ($_[1] =~ m/\ANet\:\:Socket\:\:NonBlock\=HASH\(\w+\)\Z/ois))
401 {
402 0 my $Nest = shift;
403 0 my $SRec = shift;
404 $SRec = $Nest->{'Pool'}{$SRec}
405 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$SRec = $Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
($SRec = $Nest->{'Pool'}{$SRec}) || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
($SRec = $Nest->{'Pool'}{$SRec}) || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
($SRec = $Nest->{'Pool'}{$SRec}) &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= ($SRec = $Nest->{'Pool'}{$SRec})B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
406 and return;
407 0 ▶ return wantarray ? %{scalar($SRec->Properties(@_))} :
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
408 scalar($SRec->Properties(@_));
409 };
410
411 2 my ($Nest, %Params) = @_;
412  
413 2 my %Result = ();
414  
415 2 my $Key = undef;
416 2 foreach $Key ('SelectT', 'SilenceT', 'BuffSize', 'debug')
417 8 ▶ { $Result{$Key} = defined($Nest->{$Key}) ? $Nest->{$Key} : ''; };
Branch: 1 branch
BranchTrueFalseTotal
defined $Nest->{$Key} ? : 8 0 8
418  
419 2 $Result{'Sockets'} = $Nest->{'Select'}->count();
420  
421 2 foreach $Key ('SelectT', 'SilenceT', 'BuffSize', 'debug')
422 {
423 defined($Params{$Key})
424 8 ▶ and $Nest->{$Key} = $Params{$Key};
Branch: 1 branch
BranchTrueFalseTotal
defined $Params{$Key} and $Nest->{$Key} = $Params{$Key} 0 8 8
425 };
426  
427 2 ▶ return wantarray ? %Result : \%Result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
428 };
429  
430 sub NestProperties
431 0 ▶ { return wantarray ? %{scalar(Properties(@_))} : scalar(Properties(@_)); };
Subroutine NestProperties: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
432  
433 my $Cleanup = sub($$)
434 17 ▶ {
Subroutine __ANON__: called CC=12 SCAR=38.1
435 17 my ($Nest, $SRec) = @_;
436  
437 ($SRec->{'Socket'} && $Nest->{'Pool'}{$SRec})
438 0 ▶ or &{$Die}("$SRec: bad socket");
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec} or &{$Die;}("${SRec}: bad socket") 17 0 17
Condition33%1/3
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec}
!ll&&!rl&&r
0017
MC/DC0%0/2
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec}
$SRec->{"Socket"} $Nest->{"Pool"}{$SRec}
Truth table33%1/3
A and B
A= $SRec->{"Socket"}B= $Nest->{"Pool"}{$SRec}
ABresult
0X0
100
111
439  
440 17 my $CurTime = time();
441  
442 17 ▶ if ($SRec->{'Close'})
Branch: 2 branches
BranchTrueFalseTotal
if ($SRec->{'Close'}) { } 3 14 17
elsif ($SRec->{'SilenceT'} and $SRec->{'SilenceT'} < $CurTime - $SRec->{'ATime'} and &{$BuffEmpty;}($SRec, 'Input') and &{$BuffEmpty;}($SRec, 'Output')) { } 0 28 28
443 {
444 3 ▶ if (!$SRec->{'Flush'})
Branch: 3 branches
BranchTrueFalseTotal
if (not $SRec->{'Flush'}) { } 3 0 3
elsif (&{$BuffEmpty;}($SRec, 'Output')) { } 0 0 0
elsif ($SRec->{'CloseAt'} and $SRec->{'CloseAt'} < $CurTime) { } 0 0 0
445 {
446 3 &{$ThrowMsg}($Nest, $Nest->{'debug'}, $SRec->{'Proto'}." socket $SRec closed by request");
447 3 &{$Close}($Nest, $SRec);
448 3 return;
449 }
450 0 elsif (&{$BuffEmpty}($SRec, 'Output'))
451 {
452 0 &{$ThrowMsg}($Nest, $Nest->{'debug'}, $SRec->{'Proto'}." socket $SRec closed after flush");
453 0 &{$Close}($Nest, $SRec);
454 0 return;
455 }
456 ▶ elsif ($SRec->{'CloseAt'} && ($SRec->{'CloseAt'} < $CurTime))
Condition0%0/3
$SRec->{"CloseAt"} and $SRec->{"CloseAt"} < $CurTime
!ll&&!rl&&r
000
MC/DC0%0/2
$SRec->{"CloseAt"} and $SRec->{"CloseAt"} < $CurTime
$SRec->{"CloseAt"} $SRec->{"CloseAt"} < $CurTime
Truth table0%0/3
A and B
A= $SRec->{"CloseAt"}B= $SRec->{"CloseAt"} < $CurTime
ABresult
0X0
100
111
457 {
458 0 &{$ThrowMsg}($Nest, $Nest->{'debug'}, $SRec->{'Proto'}." socket $SRec closed by flush timeout");
459 0 &{$Close}($Nest, $SRec);
460 0 return;
461 };
462 }
463 ▶ elsif ($SRec->{'SilenceT'} &&
Condition33%3/9
$SRec->{"SilenceT"} and $SRec->{"SilenceT"} < $CurTime - $SRec->{"ATime"} and &{$BuffEmpty;}($SRec, "Input") and &{$BuffEmpty;}($SRec, "Output")
!ll&&!rl&&r
1400
$SRec->{"SilenceT"} and $SRec->{"SilenceT"} < $CurTime - $SRec->{"ATime"} and &{$BuffEmpty;}($SRec, "Input")
!ll&&!rl&&r
1400
$SRec->{"SilenceT"} and $SRec->{"SilenceT"} < $CurTime - $SRec->{"ATime"}
!ll&&!rl&&r
0140
MC/DC0%0/4
$SRec->{"SilenceT"} and $SRec->{"SilenceT"} < $CurTime - $SRec->{"ATime"} and &{$BuffEmpty;}($SRec, "Input") and &{$BuffEmpty;}($SRec, "Output")
$SRec->{"SilenceT"} $SRec->{"SilenceT"} < $CurTime - $SRec->{"ATime"} &{$BuffEmpty;}($SRec, "Input") &{$BuffEmpty;}($SRec, "Output")
Truth table20%1/5
A and B and C and D
A= $SRec->{"SilenceT"}B= $SRec->{"SilenceT"} < $CurTime - $SRec->{"ATime"}C= &{$BuffEmpty;}($SRec, "Input")D= &{$BuffEmpty;}($SRec, "Output")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
464 ($SRec->{'SilenceT'} < ($CurTime - $SRec->{'ATime'})) &&
465 0 &{$BuffEmpty}($SRec, 'Input') &&
466 0 &{$BuffEmpty}($SRec, 'Output'))
467 {
468 0 &{$EOF}($Nest, $SRec, "silence timeout occurred");
469 0 return;
470 };
471 14 return sprintf("$SRec: %d in, %d out", &{$BuffSize}($SRec, 'Input'), &{$BuffSize}($SRec, 'Output'));
472 1 };
473  
474 my $NonBlock = sub($)
475 3 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
476 #if ( $^O ne 'MSWin32')
477 # {
478 # my $Flags = fcntl($_[0], F_GETFL(), 0)
479 # or &{$Die}("Can not get flags for socket: $!");
480 # fcntl($_[0], F_SETFL(), $Flags | O_NONBLOCK())
481 # or &{$Die}("Can not make socket non-blocking: $!");
482 # };
483 3 return $_[0];
484 1 };
485  
486 my $UpdatePeer = sub($$)
487 3 ▶ {
Subroutine __ANON__: called CC=2 SCAR=6.9
488 3 my ($SRec, $Sock) = @_;
489 3 my $PeerName = $Sock->peername;
490 3 ▶ if (defined($PeerName))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $PeerName) { } 2 1 3
491 {
492 2 ($SRec->{'PeerPort'}, $SRec->{'PeerAddr'}) = unpack_sockaddr_in($PeerName);
493 2 $SRec->{'PeerAddr'} = inet_ntoa($SRec->{'PeerAddr'});
494 }
495 else
496 {
497 1 $SRec->{'PeerAddr'} = '';
498 1 $SRec->{'PeerPort'} = '';
499 };
500 3 return;
501 1 };
502  
503 my $NewSRec = sub($$$%)
504 3 ▶ {
Subroutine __ANON__: called CC=9 SCAR=22.3
505 3 my ($Nest, $Socket, $CTime, $Params) = @_;
506  
507 3 $Params->{'Proto'} =~ m/\A\s*(.*)\s*\Z/;
508 3 $Params->{'Proto'} = "\U$1";
509 my $SRec = {'Socket' => $Socket,
510 'SilenceT' => (defined($Params->{'SilenceT'}) ? $Params->{'SilenceT'} : $Nest->{'SilenceT'}),
511 'BuffSize' => (defined($Params->{'BuffSize'}) ? $Params->{'BuffSize'} : $Nest->{'BuffSize'}),
512 'MaxClients' => (defined($Params->{'MaxClients'}) ? $Params->{'MaxClients'} : $Nest->{'MaxClients'}),
513 'ClientsST' => (defined($Params->{'ClientsST'}) ? $Params->{'ClientsST'} : $Nest->{'SilenceT'}),
514 'Clients' => 0,
515 'Parent' => '',
516 'BytesIn' => 0,
517 'BytesOut' => 0,
518 'CTime' => $CTime,
519 'ATime' => $CTime,
520 'Proto' => $Params->{'Proto'},
521 'TCP' => ($Params->{'Proto'} eq 'TCP'),
522 'Accept' => $Params->{'Accept'},
523 'PeerAddr' => '',
524 'PeerPort' => '',
525 'LocalAddr' => '',
526 'LocalPort' => '',
527 'Input' => [],
528 'Output' => [],
529 'Close' => 0,
530 'Flush' => 0,
531 'CloseAt' => 0,
532 'Error' => '',
533 3 ▶ 'DiscEmpty' => $Params->{'DiscEmpty'},
Branch: 4 branches
BranchTrueFalseTotal
defined $Params->{'SilenceT'} ? : 1 2 3
defined $Params->{'BuffSize'} ? : 1 2 3
defined $Params->{'MaxClients'} ? : 2 1 3
defined $Params->{'ClientsST'} ? : 1 2 3
534 };
535  
536 3 &{$UpdatePeer}($SRec, $Socket);
537  
538 3 my $SockName = $Socket->sockname;
539 3 ▶ if (defined($SockName))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $SockName) 3 0 3
540 {
541 3 ($SRec->{'LocalPort'}, $SRec->{'LocalAddr'}) = unpack_sockaddr_in($SockName);
542 3 $SRec->{'LocalAddr'} = inet_ntoa($SRec->{'LocalAddr'});
543 };
544  
545 3 ▶ if ($SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"TCP"}) 3 0 3
546 {
547 3 $SRec->{'Output'}->[0]->{'Data'} = '';
548 3 $SRec->{'Input'}->[0]->{'Data'} = '';
549 3 $SRec->{'Input'}->[0]->{'PeerAddr'} = $SRec->{'PeerAddr'};
550 3 $SRec->{'Input'}->[0]->{'PeerPort'} = $SRec->{'PeerPort'};
551 };
552  
553 defined($Params->{'Broadcast'})
554 3 ▶ and $SRec->{'Socket'}->sockopt(SO_BROADCAST, ($Params->{'Broadcast'} ? 1 : 0));
Branch: 2 branches
BranchTrueFalseTotal
defined $Params->{"Broadcast"} and $SRec->{"Socket"}->sockopt(6, $Params->{"Broadcast"} ? 1 : 0) 0 3 3
$Params->{'Broadcast'} ? : 0 0 0
555  
556 #return wantarray ? %{$SRec} : $SRec;
557 3 return bless $SRec => 'Net::Socket::NonBlock';
558 1 };
559  
560 my $AddSock = sub
561 3 ▶ {
Subroutine __ANON__: called CC=7 SCAR=23.7
562 3 my ($Nest, $newSock, $Params) = @_;
563  
564 3 ▶ $newSock or return;
Branch: 1 branch
BranchTrueFalseTotal
$newSock or return 3 0 3
565  
566 3 my $newSRec = &{$NewSRec}($Nest, $newSock, time(), $Params);
567
568 ($Nest->{'Pool'}{$newSRec} || $Nest->{'S2Rec'}{$newSock})
569 0 ▶ and &{$Die}("Socket '$newSRec' already in use");
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$newSRec} || $Nest->{"S2Rec"}{$newSock} and &{$Die;}("Socket '${newSRec}' already in use") 0 3 3
Condition33%1/3
$Nest->{"Pool"}{$newSRec} or $Nest->{"S2Rec"}{$newSock}
l!l&&r!l&&!r
003
MC/DC0%0/2
$Nest->{"Pool"}{$newSRec} or $Nest->{"S2Rec"}{$newSock}
$Nest->{"Pool"}{$newSRec} $Nest->{"S2Rec"}{$newSock}
Truth table33%1/3
A or B
A= $Nest->{"Pool"}{$newSRec}B= $Nest->{"S2Rec"}{$newSock}
ABresult
1X1
011
000
570  
571 3 ▶ $Nest->{'Select'}->add(&{$NonBlock}($newSock))
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Select"}->add(&{$NonBlock;}($newSock)) or $newSock->close and $@ = "Can not add socket to select: $@" and return 3 0 3
Condition16%1/6
$Nest->{'Select'}->add(&{$NonBlock;}($newSock)) || $newSock->close && ($@ = "Can not add socket to select: $@") && (return)
l!l
30
$newSock->close and $@ = "Can not add socket to select: $@" and return
!ll
00
$newSock->close and $@ = "Can not add socket to select: $@"
!ll
00
MC/DC0%0/2
$Nest->{'Select'}->add(&{$NonBlock;}($newSock)) || $newSock->close && ($@ = "Can not add socket to select: $@") && (return)
$Nest->{'Select'}->add(&{$NonBlock;}($newSock)) $newSock->close
Truth table33%1/3
A || B
A= $Nest->{'Select'}->add(&{$NonBlock;}($newSock))B= $newSock->close
ABresult
1X1
011
000
572 or $newSock->close()
573 and $@ = "Can not add socket to select: $@"
574 and return;
575
576 3 $Nest->{'Pool'}{$newSRec} = $newSRec;
577  
578 3 $Nest->{'S2Rec'}{$newSock} = $newSRec;
579  
580 3 return $newSRec;
581 1 };
582  
583 my $Accept = sub($$)
584 1 ▶ {
Subroutine __ANON__: called CC=6 SCAR=20.9
585 1 my ($Nest, $PRec) = @_;
586  
587 ($PRec->{'Socket'} && $Nest->{'Pool'}{$PRec})
588 0 ▶ or &{$Die}("$PRec: bad socket");
Branch: 1 branch
BranchTrueFalseTotal
$PRec->{"Socket"} and $Nest->{"Pool"}{$PRec} or &{$Die;}("${PRec}: bad socket") 1 0 1
Condition33%1/3
$PRec->{"Socket"} and $Nest->{"Pool"}{$PRec}
!ll&&!rl&&r
001
MC/DC0%0/2
$PRec->{"Socket"} and $Nest->{"Pool"}{$PRec}
$PRec->{"Socket"} $Nest->{"Pool"}{$PRec}
Truth table33%1/3
A and B
A= $PRec->{"Socket"}B= $Nest->{"Pool"}{$PRec}
ABresult
0X0
100
111
589  
590 1 ▶ if (!($PRec->{'Clients'} < $PRec->{'MaxClients'}))
Branch: 1 branch
BranchTrueFalseTotal
unless ($PRec->{"Clients"} < $PRec->{"MaxClients"}) 0 1 1
591 {
592 0 $@ = "maximum number of clients exceeded";
593 0 return;
594 };
595  
596 1 ▶ my $newSRec = &{$AddSock}($Nest, scalar($PRec->{'Socket'}->accept()), $PRec)
Branch: 1 branch
BranchTrueFalseTotal
my $newSRec = &{$AddSock;}($Nest, scalar $PRec->{"Socket"}->accept, $PRec) or return 1 0 1
597 or return;
598  
599 1 $PRec->{'Clients'}++;
600 1 $Nest->{'Pool'}{$newSRec} = $newSRec;
601 1 $Nest->{'S2Rec'}{$newSRec->{'Socket'}} = $newSRec;
602 1 $newSRec->{'Accept'} = undef;
603 1 $newSRec->{'SilenceT'} = $PRec->{'ClientsST'};
604 1 $newSRec->{'Parent'} = $PRec;
605  
606 1 ▶ if(!&{$PRec->{'Accept'}}($newSRec))
Branch: 1 branch
BranchTrueFalseTotal
unless (&{$PRec->{"Accept"};}($newSRec)) 0 1 1
607 {
608 0 $newSRec->{'Close'}++;
609 0 $@ = "external accept function returned a FALSE value";
610 0 return;
611 };
612  
613 1 return $newSRec;
614 1 };
615  
616 my $RecvTCP = sub($$$)
617 2 ▶ {
Subroutine __ANON__: called CC=6 SCAR=21.6
618 2 my ($Nest, $SRec, $ATime) = @_;
619  
620 ($SRec->{'Socket'} && $Nest->{'Pool'}{$SRec})
621 0 ▶ or &{$Die}("$SRec: bad socket");
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec} or &{$Die;}("${SRec}: bad socket") 2 0 2
Condition33%1/3
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec}
!ll&&!rl&&r
002
MC/DC0%0/2
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec}
$SRec->{"Socket"} $Nest->{"Pool"}{$SRec}
Truth table33%1/3
A and B
A= $SRec->{"Socket"}B= $Nest->{"Pool"}{$SRec}
ABresult
0X0
100
111
622  
623 2 my $BufAvail = $SRec->{'BuffSize'} - &{$BuffSize}($SRec, 'Input');
624  
625 2 ▶ ($BufAvail > 0)
Branch: 1 branch
BranchTrueFalseTotal
$BufAvail > 0 or return 0 2 0 2
626 or return 0;
627  
628 2 my $Buf = '';
629 2 my $Res = $SRec->{'Socket'}->recv($Buf, $BufAvail, 0);
630
631 2 ▶ if (!defined($Res))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Res) 0 2 2
632 {
633 0 &{$EOF}($Nest, $SRec, 'recv() fatal error');
634 0 return;
635 };
636  
637 2 ▶ if (!length($Buf))
Branch: 1 branch
BranchTrueFalseTotal
unless (length $Buf) 0 2 2
638 {
639 0 &{$EOF}($Nest, $SRec, 'EOF');
640 0 return;
641 };
642  
643 2 $SRec->{'Input'}->[0]->{'Data'} .= $Buf;
644  
645 2 $SRec->{'ATime'} = $ATime;
646 2 $SRec->{'BytesIn'} += length($Buf);
647  
648 2 return length($Buf);
649 1 };
650  
651 my $RecvUDP = sub($$$)
652 0 ▶ {
Subroutine __ANON__: not called CC=9 SCAR=45.0
653 0 my ($Nest, $SRec, $ATime) = @_;
654  
655 ($SRec->{'Socket'} && $Nest->{'Pool'}{$SRec})
656 0 ▶ or &{$Die}("$SRec: bad socket");
Branch: 1 branch
BranchTrueFalseTotal
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec} or &{$Die;}("${SRec}: bad socket") 0 0 0
Condition0%0/3
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec}
!ll&&!rl&&r
000
MC/DC0%0/2
$SRec->{"Socket"} and $Nest->{"Pool"}{$SRec}
$SRec->{"Socket"} $Nest->{"Pool"}{$SRec}
Truth table0%0/3
A and B
A= $SRec->{"Socket"}B= $Nest->{"Pool"}{$SRec}
ABresult
0X0
100
111
657  
658 0 my $BufAvail = $SRec->{'BuffSize'} - &{$BuffSize}($SRec, 'Input');
659 0 my $Received = 0;
660  
661 0 my $Sel = IO::Select->new($SRec->{'Socket'});
662 0 ▶ while($Sel->can_read(0) && ($BufAvail > $Received))
Branch: 1 branch
BranchTrueFalseTotal
if ($Sel->can_read(0) and $BufAvail > $Received) 0 0 0
Condition0%0/3
$Sel->can_read(0) and $BufAvail > $Received
!ll&&!rl&&r
000
MC/DC0%0/2
$Sel->can_read(0) and $BufAvail > $Received
$Sel->can_read(0) $BufAvail > $Received
Truth table0%0/3
A and B
A= $Sel->can_read(0)B= $BufAvail > $Received
ABresult
0X0
100
111
663 {
664 0 my $Buf = '';
665 0 my $Res = $SRec->{'Socket'}->recv($Buf, $SRec->{'BuffSize'});
666
667 0 ▶ if (!defined($Res))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Res) 0 0 0
668 {
669 0 &{$EOF}($Nest, $SRec, 'recv() fatal error');
670 0 return;
671 }
672
673 0 ▶ (length($Buf) || !$SRec->{'DiscEmpty'})
Branch: 1 branch
BranchTrueFalseTotal
length $Buf or not $SRec->{"DiscEmpty"} or next 0 0 0
Condition0%0/3
length $Buf or not $SRec->{"DiscEmpty"}
l!l&&r!l&&!r
000
MC/DC0%0/2
length $Buf or not $SRec->{"DiscEmpty"}
length $Buf not $SRec->{"DiscEmpty"}
Truth table0%0/3
A or not(B)
A= length $BufB= not $SRec->{"DiscEmpty"}
ABresult
1X1
011
000
674 or next;
675  
676 0 $Received += (length($Buf) + 20);
677 0 my $tmpHash = {'Data' => $Buf};
678 0 &{$UpdatePeer}($tmpHash, $SRec->{'Socket'});
679 0 push(@{$SRec->{'Input'}}, $tmpHash);
680 };
681  
682 $Received
683 0 ▶ and $SRec->{'ATime'} = $ATime;
Branch: 1 branch
BranchTrueFalseTotal
$Received and $SRec->{"ATime"} = $ATime 0 0 0
684  
685 0 $SRec->{'BytesIn'} += $Received;
686  
687 0 return $Received;
688 1 };
689  
690 sub IO($$)
691 6 ▶ {
Subroutine IO: called CC=26 SCAR=42.5
692 6 my ($Nest, $ErrArray) = @_;
693  
694 6 my $Result = '0 but true';
695  
696 6 ▶ $ErrArray and @{$ErrArray} = ();
Branch: 1 branch
BranchTrueFalseTotal
$ErrArray and @{$ErrArray;} = () 6 0 6
697  
698 6 $Nest->{'ErrArray'} = $ErrArray;
699  
700 6 my $CurTime = time();
701  
702 6 my $SRec = undef;
703  
704 6 foreach $SRec (values(%{$Nest->{'Pool'}}))
705 17 { &{$Cleanup}($Nest, $SRec); };
706  
707 6 my $Socket = undef;
708  
709 6 my @SockArray = $Nest->{'Select'}->can_read($Nest->{'SelectT'});
710 6 foreach $Socket (@SockArray)
711 {
712 3 $SRec = $Nest->{'S2Rec'}{$Socket};
713
714 3 ▶ if ($SRec->{'EOF'} || $SRec->{'Close'} ||
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"EOF"} or $SRec->{"Close"} or &{$BuffSize;}($SRec, "Input") >= $SRec->{"BuffSize"}) 0 3 3
Condition33%2/6
$SRec->{"EOF"} or $SRec->{"Close"} or &{$BuffSize;}($SRec, "Input") >= $SRec->{"BuffSize"}
l!l&&r!l&&!r
003
$SRec->{"EOF"} or $SRec->{"Close"}
l!l&&r!l&&!r
003
MC/DC0%0/3
$SRec->{"EOF"} or $SRec->{"Close"} or &{$BuffSize;}($SRec, "Input") >= $SRec->{"BuffSize"}
$SRec->{"EOF"} $SRec->{"Close"} &{$BuffSize;}($SRec, "Input") >= $SRec->{"BuffSize"}
Truth table25%1/4
A or B or C
A= $SRec->{"EOF"}B= $SRec->{"Close"}C= &{$BuffSize;}($SRec, "Input") >= $SRec->{"BuffSize"}
ABCresult
1XX1
01X1
0011
0000
715 3 (&{$BuffSize}($SRec, 'Input') >= $SRec->{'BuffSize'}))
716 0 { next; };
717
718 3 ▶ if ($SRec->{'Accept'} && $SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"Accept"} and $SRec->{"TCP"}) 1 2 3
Condition66%2/3
$SRec->{"Accept"} and $SRec->{"TCP"}
!ll&&!rl&&r
201
MC/DC50%1/2
$SRec->{"Accept"} and $SRec->{"TCP"}
$SRec->{"Accept"} $SRec->{"TCP"}
Truth table66%2/3
A and B
A= $SRec->{"Accept"}B= $SRec->{"TCP"}
ABresult
0X0
100
111
719 {
720 1 $Result++;
721 1 &{$Accept}($Nest, $SRec)
722 1 ▶ and &{$ThrowMsg}(undef, $Nest->{'debug'}, "$SRec: incoming connection accepted")
Condition0%0/3
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
723 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: Can not accept incoming connection: $@");
Branch: 1 branch
BranchTrueFalseTotal
&{$Accept;}($Nest, $SRec) and &{$ThrowMsg;}(undef, $Nest->{"debug"}, "${SRec}: incoming connection accepted") or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: Can not accept incoming connection: $@") 1 0 1
Condition33%1/3
&{$Accept;}($Nest, $SRec) and &{$ThrowMsg;}(undef, $Nest->{"debug"}, "${SRec}: incoming connection accepted")
!ll&&!rl&&r
001
MC/DC0%0/2
&{$Accept;}($Nest, $SRec) and &{$ThrowMsg;}(undef, $Nest->{"debug"}, "${SRec}: incoming connection accepted")
&{$Accept;}($Nest, $SRec) &{$ThrowMsg;}(undef, $Nest->{"debug"}, "${SRec}: incoming connection accepted")
Truth table33%1/3
A and B
A= &{$Accept;}($Nest, $SRec)B= &{$ThrowMsg;}(undef, $Nest->{"debug"}, "${SRec}: incoming connection accepted")
ABresult
0X0
100
111
724 1 $SRec->{'ATime'} = $CurTime;
725 1 next;
726 };
727
728
729 2 ▶ my ($Res) = &{$SRec->{'TCP'} ? $RecvTCP : $RecvUDP}($Nest, $SRec, $CurTime)
Branch: 2 branches
BranchTrueFalseTotal
my($Res) = &{$SRec->{"TCP"} ? $RecvTCP : $RecvUDP;}($Nest, $SRec, $CurTime) or next 2 0 2
$SRec->{'TCP'} ? : 2 0 2
730 or next;
731
732 2 &{$ThrowMsg}(undef, $Nest->{'debug'}, "$SRec: recv $Res bytes");
733
734 2 $Result++;
735 };
736  
737 6 my $Continue = 1;
738 6 ▶ while ($Continue)
Branch: 1 branch
BranchTrueFalseTotal
if ($Continue) 8 6 14
739 {
740 8 $Continue = 0;
741 8 my $Socket = undef;
742  
743 8 @SockArray = $Nest->{'Select'}->can_write($Nest->{'SelectT'});
744 8 foreach $Socket (@SockArray)
745 {
746 14 $SRec = $Nest->{'S2Rec'}{$Socket};
747  
748 14 my $OutRec = $SRec->{'Output'}->[0];
749  
750 14 ▶ (defined($OutRec) && !$SRec->{'EOF'})
Branch: 1 branch
BranchTrueFalseTotal
defined $OutRec and not $SRec->{"EOF"} or next 14 0 14
Condition33%1/3
defined $OutRec and not $SRec->{"EOF"}
!ll&&!rl&&r
0014
MC/DC0%0/2
defined $OutRec and not $SRec->{"EOF"}
defined $OutRec not $SRec->{"EOF"}
Truth table33%1/3
A and not(B)
A= defined $OutRecB= not $SRec->{"EOF"}
ABresult
0X0
100
111
751 or next;
752
753 14 my $DataLen = length($OutRec->{'Data'});
754
755 14 ▶ if (!$DataLen && $SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if (not $DataLen and $SRec->{"TCP"}) 12 2 14
Condition66%2/3
not $DataLen and $SRec->{"TCP"}
!ll&&!rl&&r
2012
MC/DC50%1/2
not $DataLen and $SRec->{"TCP"}
not $DataLen $SRec->{"TCP"}
Truth table66%2/3
not(A) and B
A= not $DataLenB= $SRec->{"TCP"}
ABresult
0X0
100
111
756 12 { next; }
757  
758 2 $Continue++;
759  
760 2 my $Res = $Socket->send($OutRec->{'Data'}, 0, $OutRec->{'Dest'});
761  
762 2 ▶ if (!defined($Res))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Res) 0 2 2
763 {
764 0 &{$EOF}($Nest, $SRec, "send() fatal error");
765 0 next;
766 };
767  
768 2 ▶ if (!(($Res == $DataLen) || ($! == POSIX::EWOULDBLOCK)))
Branch: 1 branch
BranchTrueFalseTotal
unless ($Res == $DataLen or $! == 11) 0 2 2
Condition33%1/3
$Res == $DataLen or $! == 11
l!l&&r!l&&!r
200
MC/DC0%0/2
$Res == $DataLen or $! == 11
$Res == $DataLen $! == 11
Truth table33%1/3
A or B
A= $Res == $DataLenB= $! == 11
ABresult
1X1
011
000
769 {
770 0 ▶ if ($SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{"TCP"}) 0 0 0
771 {
772 0 &{$EOF}($Nest, $SRec, "send() fatal error");
773 0 next;
774 };
775
776 0 my ($DP, $DA) = unpack_sockaddr_in($OutRec->{'Dest'});
777 0 $DA = inet_ntoa($DA);
778 0 $SRec->{'Error'} = "$SRec: send() error: ".($DataLen - $Res)." bytes were not sent to $DA:$DP";
779 0 ▶ &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), $SRec->{'Error'});
Condition0%0/3
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
780
781 0 shift(@{$SRec->{'Output'}});
782 0 $SRec->{'BytesOut'} += $Res;
783 0 next;
784 };
785  
786 2 $SRec->{'ATime'} = $CurTime;
787 2 $SRec->{'BytesOut'} += $Res;
788
789 2 ▶ if ($SRec->{'TCP'})
Branch: 1 branch
BranchTrueFalseTotal
if ($SRec->{'TCP'}) { } 2 0 2
790 {
791 2 substr($OutRec->{'Data'}, 0, $Res) = '';
792 }
793 else
794 {
795 0 shift(@{$SRec->{'Output'}});
796 0 &{$UpdatePeer}($SRec, $Socket);
797 };
798  
799 2 &{$ThrowMsg}(undef, ($Nest->{'debug'}), "$SRec: $Res bytes sent to ".$SRec->{'PeerAddr'}.':'.$SRec->{'PeerPort'});
800 };
801 };
802 6 return $Result;
803 };
804  
805  
806 sub SelectT
807 0 ▶ {
Subroutine SelectT: not called CC=2 SCAR=17.9
808 0 my ($Nest, $SelectT) = @_;
809 0 my $Return = $Nest->{'SelectT'};
810 0 ▶ $SelectT and $Nest->{'SelectT'} = $SelectT;
Branch: 1 branch
BranchTrueFalseTotal
$SelectT and $Nest->{"SelectT"} = $SelectT 0 0 0
811 0 return $Return;
812 };
813  
814 sub SilenceT
815 0 ▶ {
Subroutine SilenceT: not called CC=2 SCAR=17.9
816 0 my ($Nest, $SilenceT) = @_;
817 0 my $Return = $Nest->{'SilenceT'};
818 0 ▶ $SilenceT and $Nest->{'SilenceT'} = $SilenceT;
Branch: 1 branch
BranchTrueFalseTotal
$SilenceT and $Nest->{"SilenceT"} = $SilenceT 0 0 0
819 0 return $Return;
820 };
821  
822 sub Listen
823 1 ▶ {
Subroutine Listen: called CC=4 SCAR=16.6
824 1 my ($Nest, %Params) = @_;
825  
826 1 ▶ if (($Params{'Proto'} =~ m/\A\s*tcp\s*\Z/io) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($Params{"Proto"} =~ /\A\s*tcp\s*\Z/io and ref $Params{"Accept"} ne "CODE") 0 1 1
Condition33%1/3
$Params{"Proto"} =~ /\A\s*tcp\s*\Z/io and ref $Params{"Accept"} ne "CODE"
!ll&&!rl&&r
010
MC/DC0%0/2
$Params{"Proto"} =~ /\A\s*tcp\s*\Z/io and ref $Params{"Accept"} ne "CODE"
$Params{"Proto"} =~ /\A\s*tcp\s*\Z/io ref $Params{"Accept"} ne "CODE"
Truth table33%1/3
A and B
A= $Params{"Proto"} =~ /\A\s*tcp\s*\Z/ioB= ref $Params{"Accept"} ne "CODE"
ABresult
0X0
100
111
827 (ref($Params{'Accept'}) ne 'CODE'))
828 {
829 0 $@ = "'Accept' have to be a 'CODE' reference";
830 0 return;
831 };
832
833 1 ▶ my $newSRec = &{$AddSock}($Nest, IO::Socket::INET->new(%Params), \%Params)
Branch: 1 branch
BranchTrueFalseTotal
my $newSRec = &{$AddSock;}($Nest, "IO::Socket::INET"->new(%Params), \%Params) or return 1 0 1
834 or return;
835  
836 1 return $newSRec;
837 };
838  
839 sub Connect
840 1 ▶ {
Subroutine Connect: called CC=2 SCAR=7.0
841 1 my ($Nest, %Params) = @_;
842
843 1 ▶ my $newSRec = &{$AddSock}($Nest, IO::Socket::INET->new(%Params), \%Params)
Branch: 1 branch
BranchTrueFalseTotal
my $newSRec = &{$AddSock;}($Nest, "IO::Socket::INET"->new(%Params), \%Params) or return 1 0 1
844 or return;
845  
846 1 $newSRec->{'Accept'} = undef;
847  
848 1 return $newSRec;
849 };
850  
851 sub Gets
852 4 ▶ {
Subroutine Gets: called CC=4 SCAR=19.4
853 4 my $Nest = shift;
854 4 my $SRec = shift;
855 $Nest->{'Pool'}{$SRec}
856 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 4 0 4
Condition14%1/7
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l
40
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table33%1/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
857 and return;
858 4 return $Nest->{'Pool'}{$SRec}->Gets(@_);
859 };
860 sub Read
861 0 ▶ {
Subroutine Read: not called CC=4 SCAR=30.0
862 0 my $Nest = shift;
863 0 my $SRec = shift;
864 $Nest->{'Pool'}{$SRec}
865 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
866 and return;
867 0 return $Nest->{'Pool'}{$SRec}->Read(@_);
868 };
869 sub Recv
870 0 ▶ {
Subroutine Recv: not called CC=4 SCAR=30.0
871 0 my $Nest = shift;
872 0 my $SRec = shift;
873 $Nest->{'Pool'}{$SRec}
874 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
875 and return;
876 0 return $Nest->{'Pool'}{$SRec}->Recv(@_);
877 };
878 sub Puts
879 2 ▶ {
Subroutine Puts: called CC=4 SCAR=19.4
880 2 my $Nest = shift;
881 2 my $SRec = shift;
882 $Nest->{'Pool'}{$SRec}
883 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 2 0 2
Condition14%1/7
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l
20
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table33%1/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
884 and return;
885 2 return $Nest->{'Pool'}{$SRec}->Puts(@_);
886 };
887 sub Send
888 0 ▶ {
Subroutine Send: not called CC=4 SCAR=30.0
889 0 my $Nest = shift;
890 0 my $SRec = shift;
891 $Nest->{'Pool'}{$SRec}
892 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
893 and return;
894 0 return $Nest->{'Pool'}{$SRec}->Send(@_);
895 };
896 sub PeerAddr
897 0 ▶ {
Subroutine PeerAddr: not called CC=4 SCAR=30.0
898 0 my $Nest = shift;
899 0 my $SRec = shift;
900 $Nest->{'Pool'}{$SRec}
901 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
902 and return;
903 0 return $Nest->{'Pool'}{$SRec}->PeerAddr(@_);
904 };
905 sub PeerPort
906 0 ▶ {
Subroutine PeerPort: not called CC=4 SCAR=30.0
907 0 my $Nest = shift;
908 0 my $SRec = shift;
909 $Nest->{'Pool'}{$SRec}
910 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
911 and return;
912 0 return $Nest->{'Pool'}{$SRec}->PeerPort(@_);
913 };
914 sub LocalAddr
915 0 ▶ {
Subroutine LocalAddr: not called CC=4 SCAR=30.0
916 0 my $Nest = shift;
917 0 my $SRec = shift;
918 $Nest->{'Pool'}{$SRec}
919 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
920 and return;
921 0 return $Nest->{'Pool'}{$SRec}->LocalAddr(@_);
922 };
923 sub LocalPort
924 1 ▶ {
Subroutine LocalPort: called CC=4 SCAR=19.4
925 1 my $Nest = shift;
926 1 my $SRec = shift;
927 $Nest->{'Pool'}{$SRec}
928 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 1 0 1
Condition14%1/7
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l
10
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table33%1/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
929 and return;
930 1 return $Nest->{'Pool'}{$SRec}->LocalPort(@_);
931 };
932 sub Handle
933 0 ▶ {
Subroutine Handle: not called CC=4 SCAR=30.0
934 0 my $Nest = shift;
935 0 my $SRec = shift;
936 $Nest->{'Pool'}{$SRec}
937 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 0 0 0
Condition0%0/8
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l&&r!l&&!r
000
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table0%0/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
938 and return;
939 0 return $Nest->{'Pool'}{$SRec}->Handle(@_);
940 };
941 sub Close
942 3 ▶ {
Subroutine Close: called CC=4 SCAR=19.4
943 3 my $Nest = shift;
944 3 my $SRec = shift;
945 $Nest->{'Pool'}{$SRec}
946 0 ▶ or &{$ThrowMsg}($Nest, ($^W || $Nest->{'debug'}), "$SRec: bad socket name")
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"Pool"}{$SRec} or &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return 3 0 3
Condition14%1/7
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
l!l
30
&{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name") and return
!ll
00
$^W || $Nest->{'debug'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Nest->{'Pool'}{$SRec} || &{$ThrowMsg;}($Nest, $^W || $Nest->{'debug'}, "${SRec}: bad socket name") && (return)
$Nest->{'Pool'}{$SRec} &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
MC/DC0%0/2
$^W || $Nest->{'debug'}
$^W $Nest->{'debug'}
Truth table33%1/3
A || B
A= $Nest->{'Pool'}{$SRec}B= &{$ThrowMsg;}($Nest, $^W || $Nest->{"debug"}, "${SRec}: bad socket name")
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $^WB= $Nest->{'debug'}
ABresult
1X1
011
000
947 and return;
948 3 return $Nest->{'Pool'}{$SRec}->Close(@_);
949 };
950  
951 sub DESTROY
952 1 ▶ {
Subroutine DESTROY: called CC=3 SCAR=12.0
953 1 my ($Nest) = @_;
954 1 foreach my $SRec (values(%{$Nest->{'Pool'}}))
955 0 { &{$Close}($Nest, $SRec); };
956 1 delete($Nest->{'Select'});
957 1 ▶ $Nest->{'debug'}
Branch: 1 branch
BranchTrueFalseTotal
$Nest->{"debug"} and warn "Socket nest $Nest destroyed" 0 1 1
958 and warn "Socket nest $Nest destroyed";
959 };
960  
961 1 1;
962 __END__
↑ Summary