| 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')
MC/DC0%0/1
delete $arg{'port'} || die('port required')
delete $arg{'port'}
Truth table0%0/2
A
A= delete $arg{'port'}
| |||||||||||||
| 21 | 0 | ▶ | my $cb = delete $arg{cb} || die "cb required"; | ||||||||||
|
Condition0%0/2
delete $arg{'cb'} || die('cb required')
MC/DC0%0/1
delete $arg{'cb'} || die('cb required')
delete $arg{'cb'}
Truth table0%0/2
A
A= delete $arg{'cb'}
| |||||||||||||
| 22 | 0 | ▶ | for (qw(fd poll)) { carp "$_ ignored" if delete $arg{$_}; } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | |||||||||||||
| 24 | 0 | my $proto = getprotobyname('tcp'); | |||||||||||
| 25 | 0 | ▶ | socket(my $sock = gensym, PF_INET, SOCK_STREAM, $proto) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 26 | or die "socket: $!"; | ||||||||||||
| 27 | 0 | ▶ | setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, pack('l', 1)) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 28 | or die "setsockopt: $!"; | ||||||||||||
| 29 | 0 | ▶ | bind($sock, sockaddr_in($port, INADDR_ANY)) or die "bind: $!"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 0 | ▶ | listen($sock, SOMAXCONN) or die "listen: $!"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 38 | 0 | $cb->($w, $sock); | |||||||||||
| 39 | 0 | }); | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 1 | 1; | |||||||||||
| 43 | |||||||||||||
| 44 | __END__ | ||||||||||||