blib/lib/Net/TCP/Server.pm

filter: Statementstmt 46.1% 24 / 52 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 66.6% 8 / 12 Podpod 50.0% 2 / 4 totaltotal 24.1% 34 / 141 CC 24 SCAR 47.1
CC
24
Cov
22%
init
200.4
new
88.7
carp
2.0
CRAP 111.6
« blib/lib/Net/Inet.pm ↑ Summary blib/lib/Net/TCP.pm »
1 # Copyright 1997,2002 Spider Boardman.
2 # All rights reserved.
3 #
4 # Automatic licensing for this software is available. This software
5 # can be copied and used under the terms of the GNU Public License,
6 # version 1 or (at your option) any later version, or under the
7 # terms of the Artistic license. Both of these can be found with
8 # the Perl distribution, which this software is intended to augment.
9 #
10 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
11 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13  
14 # rcsid: "@(#) $Id: Server.dat,v 1.16 2002/03/30 10:11:36 spider Exp $"
15  
16 package Net::TCP::Server;
17 1 ▶use 5.004_04;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 #use Carp;
21 0 ▶sub carp { require Carp; goto &Carp::carp; }
Subroutine carp: not called CC=1 SCAR=6.9
Pod undocumented
22 0 ▶sub croak { require Carp; goto &Carp::croak; }
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
23 1 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 $VERSION = '1.0';
27 1 eval "sub Version () { __PACKAGE__ . ' v$VERSION' }";
28 }
29  
30 #use AutoLoader;
31 #use Exporter (); # we inherit what we need here from Net::Gen
32 #use Net::Inet;
33 #use Net::Gen;
34 1 ▶use Net::TCP 1.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36  
37 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 @ISA = 'Net::TCP';
39  
40 # Items to export into callers namespace by default
41 # (move infrequently used names to @EXPORT_OK below)
42 1 @EXPORT = qw(
43 );
44  
45 # Other items we are prepared to export if requested
46 1 @EXPORT_OK = qw(
47 );
48  
49 # Tags:
50 1 %EXPORT_TAGS = (
51 ALL => [@EXPORT, @EXPORT_OK],
52 );
53 # *AUTOLOAD = \$Net::Gen::AUTOLOAD;
54 }
55  
56 # sub AUTOLOAD inherited from Net::Gen (via Net::TCP)
57  
58 # However, since 5.003_96 will make simple subroutines not inherit AUTOLOAD...
59 #sub AUTOLOAD
60 #{
61 # #$Net::Gen::AUTOLOAD = $AUTOLOAD;
62 # goto &Net::Gen::AUTOLOAD;
63 #}
64  
65  
66 # Preloaded methods go here. Autoload methods go after __END__, and are
67 # processed by the autosplit program.
68  
69 # Can't autoload routines which we could get without autoloading by
70 # inheritance, so new() and init() have to be here.
71  
72 #& new(classname, [[hostspec,] service,] [\%params]) : {$self | undef}
73 sub new
74 0 ▶{
Subroutine new: not called CC=10 SCAR=44.8
Pod documented
75 1 ▶ use attrs qw(locked);
Subroutine BEGIN: called CC=1 SCAR=0.0
76 0 $_[0]->_trace(\@_,1);
77 0 my ($xclass, @Args) = @_;
78 0 ▶ if (@Args == 2 && ref $Args[1] && ref($Args[1]) eq 'HASH' or
Branch: 1 branch
BranchTrueFalseTotal
if (@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH" or @Args == 1 and not ref $Args[0]) 0 0 0
Condition0%0/12
@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH" or @Args == 1 and not ref $Args[0]
l!l&&r!l&&!r
000
@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH"
!ll&&!rl&&r
000
@Args == 2 and ref $Args[1]
!ll&&!rl&&r
000
@Args == 1 and not ref $Args[0]
!ll&&!rl&&r
000
MC/DC0%0/5
@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH" or @Args == 1 and not ref $Args[0]
@Args == 2 ref $Args[1] ref $Args[1] eq "HASH" @Args == 1 not ref $Args[0]
Truth table0%0/10
A and B and C or D and not(E)
A= @Args == 2B= ref $Args[1]C= ref $Args[1] eq "HASH"D= @Args == 1E= not ref $Args[0]
ABCDEresult
111XX1
0XX111
10X111
110111
0XX0X0
0XX100
10X0X0
10X100
1100X0
110100
79 @Args == 1 and not ref $Args[0]) {
80 0 unshift(@Args, undef); # thishost spec
81 }
82 0 my $self = $xclass->SUPER::new(@Args);
83 0 ▶ return undef unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
84 0 $self->setparams({reuseaddr => 1}, -1);
85 0 ▶ $xclass = ref $xclass if ref $xclass;
Branch: 1 branch
BranchTrueFalseTotal
if ref $xclass 0 0 0
86 0 ▶ if ($xclass eq __PACKAGE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xclass eq __PACKAGE__) 0 0 0
87 0 ▶ unless ($self->init(@Args)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->init(@Args)) 0 0 0
88 0 local $!; # protect returned errno value
89 0 undef $self; # against excess closes in perl core
90 0 undef $self; # another statement needed for sequencing
91 }
92 }
93 0 $self;
94 }
95  
96 #& init($self, [@stuff]) : {$self | undef}
97 sub init
98 0 ▶{
Subroutine init: not called CC=15 SCAR=53.0
Pod documented
99 1 ▶ use attrs qw(locked method);
Subroutine BEGIN: called CC=1 SCAR=0.0
100 0 my ($self, @Args) = @_;
101 0 ▶ if (@Args == 2 && ref $Args[1] && ref $Args[1] eq 'HASH' or
Branch: 1 branch
BranchTrueFalseTotal
if (@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH" or @Args == 1 and not ref $Args[0]) 0 0 0
Condition0%0/12
@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH" or @Args == 1 and not ref $Args[0]
l!l&&r!l&&!r
000
@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH"
!ll&&!rl&&r
000
@Args == 2 and ref $Args[1]
!ll&&!rl&&r
000
@Args == 1 and not ref $Args[0]
!ll&&!rl&&r
000
MC/DC0%0/5
@Args == 2 and ref $Args[1] and ref $Args[1] eq "HASH" or @Args == 1 and not ref $Args[0]
@Args == 2 ref $Args[1] ref $Args[1] eq "HASH" @Args == 1 not ref $Args[0]
Truth table0%0/10
A and B and C or D and not(E)
A= @Args == 2B= ref $Args[1]C= ref $Args[1] eq "HASH"D= @Args == 1E= not ref $Args[0]
ABCDEresult
111XX1
0XX111
10X111
110111
0XX0X0
0XX100
10X0X0
10X100
1100X0
110100
102 @Args == 1 and not ref $Args[0]) {
103 0 unshift(@Args, undef); # thishost spec
104 }
105 0 ▶ return undef unless $self->_hostport('this',\@Args);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_hostport("this", \@Args) 0 0 0
106 0 ▶ return undef unless $self->SUPER::init;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::init 0 0 0
107 0 ▶ if ($self->getparam('srcaddrlist') && !$self->isbound) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getparam("srcaddrlist") and not $self->isbound) 0 0 0
Condition0%0/3
$self->getparam("srcaddrlist") and not $self->isbound
!ll&&!rl&&r
000
MC/DC0%0/2
$self->getparam("srcaddrlist") and not $self->isbound
$self->getparam("srcaddrlist") not $self->isbound
Truth table0%0/3
A and not(B)
A= $self->getparam("srcaddrlist")B= not $self->isbound
ABresult
0X0
100
111
108 0 ▶ return undef unless $self->bind;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->bind 0 0 0
109 }
110 0 ▶ if ($self->isbound && !$self->didlisten) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isbound and not $self->didlisten) 0 0 0
Condition0%0/3
$self->isbound and not $self->didlisten
!ll&&!rl&&r
000
MC/DC0%0/2
$self->isbound and not $self->didlisten
$self->isbound not $self->didlisten
Truth table0%0/3
A and not(B)
A= $self->isboundB= not $self->didlisten
ABresult
0X0
100
111
111 0 ▶ return undef unless $self->isconnected or $self->listen;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isconnected or $self->listen 0 0 0
Condition0%0/3
$self->isconnected or $self->listen
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->isconnected or $self->listen
$self->isconnected $self->listen
Truth table0%0/3
A or B
A= $self->isconnectedB= $self->listen
ABresult
1X1
011
000
112 }
113 0 $self;
114 }
115  
116 # maybe someday add some fork+accept handling here?
117  
118 1 1;
119  
120 # autoloaded methods go after the END token (& pod) below
121  
122 __END__
« blib/lib/Net/Inet.pm ↑ Summary blib/lib/Net/TCP.pm »