| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::QMQP; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
957
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
54
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
103
|
|
|
6
|
1
|
|
|
1
|
|
1139
|
use IO::Socket; |
|
|
1
|
|
|
|
|
38722
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = "0.01"; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
664
|
use base qw( Class::Accessor ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1577
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(sender recipients host message timeout port debug) ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
17
|
0
|
|
0
|
|
|
|
my $type = ref($self) || $self; |
|
18
|
0
|
|
|
|
|
|
my %args = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $obj = $type->SUPER::new(\%args); |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
0
|
|
|
|
$obj->{host} ||= 'localhost'; |
|
23
|
0
|
|
0
|
|
|
|
$obj->{timeout} ||= 120; |
|
24
|
0
|
|
0
|
|
|
|
$obj->{port} ||= 628; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $obj; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub queueing |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $buff = _netstring($self->message); |
|
34
|
0
|
|
|
|
|
|
$buff .= _netstring($self->sender); |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if( ref($self->recipients) eq 'ARRAY' ){ |
|
37
|
0
|
|
|
|
|
|
$buff .= join("",map{_netstring($_)}@{$self->recipients}); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
}else{ |
|
39
|
0
|
|
|
|
|
|
$buff .= _netstring($self->recipients); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$buff = _netstring($buff); |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
my $sock = IO::Socket::INET->new(PeerAddr => $self->host, |
|
45
|
|
|
|
|
|
|
PeerPort => $self->port, |
|
46
|
|
|
|
|
|
|
Proto => 'tcp', |
|
47
|
|
|
|
|
|
|
Timeout => $self->timeout, |
|
48
|
|
|
|
|
|
|
) or die($@); |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$sock->autoflush(1); |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
carp($buff) if $self->debug; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
print $sock $buff; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $res = join("",<$sock>); |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
close($sock); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $res; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _netstring |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
0
|
|
|
0
|
|
|
my $str = shift; |
|
66
|
0
|
|
|
|
|
|
return sprintf("%d:$str,",length($str)); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |