line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::Input::Socket::UDP; |
2
|
2
|
|
|
2
|
|
1514
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
3
|
2
|
|
|
2
|
|
474
|
use AnyEvent; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
36
|
|
4
|
2
|
|
|
2
|
|
1024
|
use AnyEvent::Handle::UDP; |
|
2
|
|
|
|
|
58852
|
|
|
2
|
|
|
|
|
139
|
|
5
|
2
|
|
|
2
|
|
22
|
use Scalar::Util qw/ weaken /; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
152
|
|
6
|
2
|
|
|
2
|
|
13
|
use namespace::clean -except => 'meta'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with qw/ |
9
|
|
|
|
|
|
|
Message::Passing::Role::Input |
10
|
|
|
|
|
|
|
Message::Passing::Role::HasHostnameAndPort |
11
|
|
|
|
|
|
|
Message::Passing::Role::HasErrorChain |
12
|
|
|
|
|
|
|
/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has '+hostname' => ( |
15
|
|
|
|
|
|
|
default => sub { 'localhost' }, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has '+port' => ( |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
|
|
sub _default_port { die "You must supply a port #" } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has handle => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
builder => '_build_handle', |
27
|
|
|
|
|
|
|
lazy => 1, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub BUILD { |
31
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
$self->handle; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _send_data { |
36
|
0
|
|
|
0
|
|
|
my ($self, $data, $from_addr) = @_; |
37
|
0
|
|
|
|
|
|
$self->output_to->consume($data); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _build_handle { |
41
|
0
|
|
|
0
|
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
weaken($self); |
43
|
|
|
|
|
|
|
AnyEvent::Handle::UDP->new( |
44
|
|
|
|
|
|
|
bind => [ $self->hostname, $self->port ], |
45
|
|
|
|
|
|
|
on_recv => sub { |
46
|
0
|
|
|
0
|
|
|
my ($data, $h, $from_addr) = @_; |
47
|
|
|
|
|
|
|
# The output can optionally drop from addr. |
48
|
0
|
|
|
|
|
|
$self->_send_data($data, $from_addr); |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
on_error => sub { |
51
|
0
|
|
|
0
|
|
|
my ($h, $fatal, $msg) = @_; |
52
|
0
|
|
|
|
|
|
$self->error->consume($msg); |
53
|
|
|
|
|
|
|
}, |
54
|
0
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Message::Passing::Input::Socket::UDP - UDP input |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
An input which gets messages from a UDP network socket using |
66
|
|
|
|
|
|
|
L. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 hostname |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The hostname L will bind to. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 port |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The port L will bind to. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SPONSORSHIP |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This module exists due to the wonderful people at Suretec Systems Ltd. |
85
|
|
|
|
|
|
|
who sponsored its development for its |
86
|
|
|
|
|
|
|
VoIP division called SureVoIP for use with |
87
|
|
|
|
|
|
|
the SureVoIP API - |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
See L. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|