File Coverage

blib/lib/WWW/Slides/Controller/UDP.pm
Criterion Covered Total %
statement 28 28 100.0
branch 4 4 100.0
condition n/a
subroutine 8 8 100.0
pod n/a
total 40 40 100.0


line stmt bran cond sub pod time code
1             package WWW::Slides::Controller::UDP;
2             {
3 3     3   43111 use version; our $VERSION = qv('0.0.9');
  3         5972  
  3         19  
4              
5 3     3   255 use warnings;
  3         6  
  3         83  
6 3     3   13 use strict;
  3         6  
  3         73  
7 3     3   15 use Carp;
  3         4  
  3         223  
8 3     3   2099 use English qw( -no_match_vars );
  3         10083  
  3         21  
9              
10 3     3   4551 use Object::InsideOut qw( WWW::Slides::Controller::Single );
  3         174055  
  3         21  
11 3     3   5345 use IO::Socket;
  3         35713  
  3         164  
12              
13             # Module implementation here
14             my @port : Field # Port to listen to
15             : Std(Name => 'port', Private => 1) : Get(Name => 'port')
16             : Arg(Name => 'port', Mandatory => 1);
17              
18             sub _init : PreInit { # Generate the UDP socket
19 3         18073 my $self = shift;
20 3         7 my ($args) = @_;
21 3 100       32 croak "missing mandatory argument 'port'"
22             unless exists $args->{port};
23 2 100       12 $args->{in_handle} = IO::Socket::INET->new(
24             Proto => 'udp',
25             LocalPort => $args->{port},
26             ) or croak "cannot create socket: $OS_ERROR";
27 3     3   1798 } ## end sub _init :
  3         6  
  3         20  
28             }
29             1; # Magic true value required at end of module
30             __END__