blib/lib/Net/UDP.pm

filter: Statementstmt 78.3% 47 / 60 Branchbran 35.7% 5 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 71.4% 10 / 14 Podpod 33.3% 1 / 3 totaltotal 60.5% 63 / 104 CC 11 SCAR 25.4
CC
11
Cov
63%
_addrinfo
42.0
new
6.4
carp
2.0
CRAP 12.7
« blib/lib/Net/UNIX.pm ↑ Summary blib/lib/Net/UNIX/Server.pm »
1 # Copyright 1995,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: UDP.dat,v 1.21 2002/03/30 10:10:55 spider Exp $"
15  
16 package Net::UDP;
17 1 ▶use 5.004_04; # new minimum Perl version for this package
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 *AUTOLOAD);
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 1 ▶use AutoLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 1 ▶use Net::Inet 1.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use Net::Gen 1.0 ':sockvals', ':families';
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 @ISA = 'Net::Inet';
37 1 *AUTOLOAD = \$Net::Gen::AUTOLOAD;
38 }
39  
40 # Cheat on AUTOLOAD inheritance.
41 sub AUTOLOAD
42 0 ▶{
Subroutine AUTOLOAD: not called CC=1 SCAR=6.9
43 #$Net::Gen::AUTOLOAD = $AUTOLOAD;
44 0 goto &Net::Gen::AUTOLOAD;
45 }
46  
47 # Preloaded methods go here. Autoload methods go after
48 # __END__, and are processed by the autosplit program.
49  
50 # No new socket options for UDP
51  
52 # Module-specific object options
53  
54 1 my @Keys = qw(unbuffered_input unbuffered_output);
55 1 my @CodeKeys = qw(unbuffered_IO unbuffered_io);
56 1 my %CodeKeys;
57 1 @CodeKeys{@CodeKeys} = (\&_setbuf_unbuf) x @CodeKeys;
58  
59 1 my %Keys; # for only calling registration routines once
60  
61 sub new
62 1 ▶{
Subroutine new: called CC=6 SCAR=18.5
Pod documented
63 1 ▶ use attrs qw(locked);
Subroutine BEGIN: called CC=1 SCAR=0.0
64 1 my($class,@args) = @_;
65 1 my $self = $class->SUPER::new(@args);
66 1 ▶ $class = ref $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 1 1
67 1 ▶ if ($self) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self) 1 0 1
68 1 ▶ if (%Keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (%Keys) { } 0 1 1
69 0 $ {*$self}{Keys} = { %Keys } ;
70 }
71 else {
72 1 $self->register_param_keys(\@Keys);
73 1 $self->register_param_handlers(\%CodeKeys);
74 1 %Keys = %{ $ {*$self}{Keys} } ;
75 }
76 # no new sockopts for UDP?
77 # set our required parameters
78 1 $self->setparams({type => SOCK_DGRAM,
79 proto => IPPROTO_UDP,
80 IPproto => 'udp',
81 netgen_fakeconnect => 1,
82 unbuffered_output => 0,
83 unbuffered_input => 0}, -1);
84 1 ▶ if ($class eq __PACKAGE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq __PACKAGE__) 1 0 1
85 1 ▶ unless ($self->init(@args)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->init(@args)) 1 0 1
86 1 local $!; # protect returned errno value
87 1 undef $self; # against excess closes in perl core
88 1 undef $self; # another statement needed for sequencing
89 }
90 }
91 }
92 1 $self;
93 }
94  
95 #& _addrinfo($this, $sockaddr, [numeric_only]) : @list
96 sub _addrinfo
97 0 ▶{
Subroutine _addrinfo: not called CC=6 SCAR=37.4
98 0 my($this,@args,@r) = @_;
99 0 @r = $this->SUPER::_addrinfo(@args);
100 0 ▶ unless(!@r or $args[1] or ref($this) or $r[2] ne $r[3]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not @r or $args[1] or ref $this or $r[2] ne $r[3]) 0 0 0
Condition0%0/9
not @r or $args[1] or ref $this or $r[2] ne $r[3]
l!l&&r!l&&!r
000
not @r or $args[1] or ref $this
l!l&&r!l&&!r
000
not @r or $args[1]
l!l&&r!l&&!r
000
MC/DC0%0/4
not @r or $args[1] or ref $this or $r[2] ne $r[3]
not @r $args[1] ref $this $r[2] ne $r[3]
Truth table0%0/5
not(A) or B or C or D
A= not @rB= $args[1]C= ref $thisD= $r[2] ne $r[3]
ABCDresult
1XXX1
01XX1
001X1
00011
00000
101 0 $this = getservbyport(htons($r[3]), 'udp');
102 0 ▶ $r[2] = $this if defined $this;
Branch: 1 branch
BranchTrueFalseTotal
if defined $this 0 0 0
103 }
104 0 @r;
105 }
106  
107 # autoloaded methods go after the END token (& pod) below
108  
109 # hack to ensure that autoloading in Net::Gen doesn't override these...
110 # not needed currently, but keep it in mind
111 #sub PRINT { goto &_UDP_PRINT; }
112 #sub READLINE { goto &_UDP_READLINE; }
113  
114 1 1;
115 __END__
« blib/lib/Net/UNIX.pm ↑ Summary blib/lib/Net/UNIX/Server.pm »