tcplisten.pm

filter: Statementstmt 64.5% 31 / 48 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 1 totaltotal 51.2% 40 / 78 CC 10 SCAR 37.3
CC
10
Cov
48%
new
90.0
__ANON__
6.0
BEGIN
1.0
CRAP 41.5
↑ Summary tcpsession.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Event::tcplisten;
3 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Event 0.50;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Event::Watcher qw(R W T);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 require Event::io;
10 1 ▶use base 'Event::io';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 $VERSION = '0.06';
13  
14 1 'Event::Watcher'->register;
15  
16 0 ▶sub new {
Subroutine new: not called CC=9 SCAR=45.0
Pod undocumented
17 0 my $class = shift;
18 0 my %arg = @_;
19  
20 0 ▶ my $port = delete $arg{port} || die "port required";
Condition0%0/2
delete $arg{'port'} || die('port required')
l!l
00
MC/DC0%0/1
delete $arg{'port'} || die('port required')
delete $arg{'port'}
Truth table0%0/2
A
A= delete $arg{'port'}
Aresult
11
00
21 0 ▶ my $cb = delete $arg{cb} || die "cb required";
Condition0%0/2
delete $arg{'cb'} || die('cb required')
l!l
00
MC/DC0%0/1
delete $arg{'cb'} || die('cb required')
delete $arg{'cb'}
Truth table0%0/2
A
A= delete $arg{'cb'}
Aresult
11
00
22 0 ▶ for (qw(fd poll)) { carp "$_ ignored" if delete $arg{$_}; }
Branch: 1 branch
BranchTrueFalseTotal
if delete $arg{$_} 0 0 0
23  
24 0 my $proto = getprotobyname('tcp');
25 0 ▶ socket(my $sock = gensym, PF_INET, SOCK_STREAM, $proto)
Branch: 1 branch
BranchTrueFalseTotal
socket my $sock = &gensym(), 2, 1, $proto or die "socket: $!" 0 0 0
26 or die "socket: $!";
27 0 ▶ setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, pack('l', 1))
Branch: 1 branch
BranchTrueFalseTotal
setsockopt $sock, 1, 2, "\1\0\0\0" or die "setsockopt: $!" 0 0 0
28 or die "setsockopt: $!";
29 0 ▶ bind($sock, sockaddr_in($port, INADDR_ANY)) or die "bind: $!";
Branch: 1 branch
BranchTrueFalseTotal
bind $sock, sockaddr_in($port, "\0\0\0\0") or die "bind: $!" 0 0 0
30 0 ▶ listen($sock, SOMAXCONN) or die "listen: $!";
Branch: 1 branch
BranchTrueFalseTotal
listen $sock, 4096 or die "listen: $!" 0 0 0
31  
32 $class->SUPER::new(%arg, fd => $sock, poll => R, reentrant => 0,
33 0 ▶ max_cb_tm => 5, cb => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
34 0 my ($e) = @_;
35 0 my $w=$e->w;
36 0 my $sock = gensym;
37 0 ▶ accept $sock, $w->fd or return;
Branch: 1 branch
BranchTrueFalseTotal
accept $sock, $w->fd or return 0 0 0
38 0 $cb->($w, $sock);
39 0 });
40 }
41  
42 1 1;
43  
44 __END__
↑ Summary tcpsession.pm »