line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZMQ::LibZMQ3::LibZMQ2; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14331
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
70
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
193
|
use ZMQ::LibZMQ3; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
ZMQ::LibZMQ3::LibZMQ2 - Seamlessly Run LibZMQ Progs against LibZMQ3 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.02 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This provides an interface compatible with ZMQ::LibZMQ2, but runs against |
24
|
|
|
|
|
|
|
ZMQ::LibZMQ3. For more information and documentation, see ZMQ::LibZMQ2 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
To port, assuming no fully qualified namespace calls, change |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use ZMQ::LibZMQ2; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
to |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use ZMQ::LibZMQ3::LibZMQ2; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 Porting Implementation and Caveats |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
There are a few specific issues that come up when porting LibZMQ2 applications |
37
|
|
|
|
|
|
|
to LibZMQ3. This module attempts to provide a basic wrapper, preventing those |
38
|
|
|
|
|
|
|
most common issues from surfacing. This is not intended for new development, |
39
|
|
|
|
|
|
|
but for cases where existing code uses ZMQ::LibZMQ2 and you need to deploy |
40
|
|
|
|
|
|
|
against LibZMQ3. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The primary cases covered are: |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item renamed methods |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
For example, zmq_recv becomes zmq_recvmsg. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item different return value semantics |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
For example, zmq_sendmsg returning positive ints on success on 3.x while |
53
|
|
|
|
|
|
|
zmq_send returns 0 on success in libzmq2 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item poll argument semantics |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The argument is now in miliseconds rather than microseconds, so without wrapping |
58
|
|
|
|
|
|
|
this, applications poll for 1000 times as long. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
There are, however, a very few specific cases not covered by the porting layer. |
63
|
|
|
|
|
|
|
For the most part these are internal details that programs hopefully avoid |
64
|
|
|
|
|
|
|
caring about but they were found during the test cases copied from ZMQ::LibZMQ2. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
These include: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item object class names |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Objects are blessed in the LibZMQ3 namespace instead of the LibZMQ2 namespace. |
73
|
|
|
|
|
|
|
For example, a socket is blessed as ZMQ::LibZMQ3::Socket rather than |
74
|
|
|
|
|
|
|
ZMQ::LibZMQ2::Socket. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item object internals |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Object reference semantics are not guaranteed to be useful across |
79
|
|
|
|
|
|
|
implementations. For example, sockets were blessed scalar references in |
80
|
|
|
|
|
|
|
LibZMQ2, but they are not in LibZMQ3. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The above caveats are fairly minor, and are expected not to affect most |
85
|
|
|
|
|
|
|
applications. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 EXPORT |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item zmq_errno |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item zmq_strerror |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item zmq_init |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item zmq_socket |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item zmq_bind |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item zmq_connect |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item zmq_close |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item zmq_getsockopt |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item zmq_setsockopt |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item zmq_send |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item zmq_recv |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item zmq_msg_init |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item zmq_msg_init_data |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item zmq_msg_init_size |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item zmq_msg_copy |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item zmq_msg_move |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item zmq_msg_close |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item zmq_msg_poll |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item zmq_version |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item zmq_device |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item zmq_getsockopt_int |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item zmq_getsockopt_int64 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item zmq_getsockopt_string |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item zmq_getsockopt_uint64 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item zmq_setsockopt_int |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item zmq_setsockopt_int64 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item zmq_setsockopt_string |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item zmq_setsockopt_uint64 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
use base qw(Exporter); |
152
|
|
|
|
|
|
|
our @EXPORT = qw( |
153
|
|
|
|
|
|
|
zmq_errno zmq_strerror |
154
|
|
|
|
|
|
|
zmq_init zmq_term zmq_socket zmq_bind zmq_connect zmq_close |
155
|
|
|
|
|
|
|
zmq_getsockopt zmq_setsockopt |
156
|
|
|
|
|
|
|
zmq_send zmq_recv |
157
|
|
|
|
|
|
|
zmq_msg_init zmq_msg_init_data zmq_msg_init_size |
158
|
|
|
|
|
|
|
zmq_msg_data zmq_msg_size |
159
|
|
|
|
|
|
|
zmq_msg_copy zmq_msg_move zmq_msg_close |
160
|
|
|
|
|
|
|
zmq_poll zmq_version zmq_device |
161
|
|
|
|
|
|
|
zmq_setsockopt_int zmq_setsockopt_int64 zmq_setsockopt_string |
162
|
|
|
|
|
|
|
zmq_setsockopt_uint64 zmq_getsockopt_int zmq_getsockopt_int64 |
163
|
|
|
|
|
|
|
zmq_getsockopt_string zmq_getsockopt_uintint64 |
164
|
|
|
|
|
|
|
); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# Function override map: |
167
|
|
|
|
|
|
|
# libzmq2 => libzmq3 |
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
# if you need to skip, you can do |
170
|
|
|
|
|
|
|
# |
171
|
|
|
|
|
|
|
# libzmq2 => 0 |
172
|
|
|
|
|
|
|
# |
173
|
|
|
|
|
|
|
# and then define your own function |
174
|
|
|
|
|
|
|
my %fmap = ( |
175
|
|
|
|
|
|
|
zmq_send => 0, |
176
|
|
|
|
|
|
|
zmq_recv => 'zmq_recvmsg', |
177
|
|
|
|
|
|
|
zmq_poll => 0, |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
{ |
181
|
|
|
|
|
|
|
no strict 'refs'; |
182
|
|
|
|
|
|
|
no warnings 'once'; |
183
|
|
|
|
|
|
|
my $pkg = __PACKAGE__; |
184
|
|
|
|
|
|
|
*{"${pkg}::$_->{export}"} = *{"ZMQ::LibZMQ3::$_->{import}"} |
185
|
|
|
|
|
|
|
for map { |
186
|
|
|
|
|
|
|
my $target = $_; |
187
|
|
|
|
|
|
|
$target = $fmap{$_} if exists $fmap{$_}; |
188
|
|
|
|
|
|
|
$target ? { import => $target, export => $_ } : (); |
189
|
|
|
|
|
|
|
} @EXPORT; |
190
|
|
|
|
|
|
|
}; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
no warnings 'redefine'; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub zmq_poll { |
195
|
|
|
|
|
|
|
my $timeout = pop @_; |
196
|
|
|
|
|
|
|
push @_, $timeout / 1000; |
197
|
|
|
|
|
|
|
return ZMQ::LibZMQ3::zmq_poll(@_); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub zmq_send { |
201
|
|
|
|
|
|
|
my $rv = ZMQ::LibZMQ3::zmq_sendmsg(@_) || 0; |
202
|
|
|
|
|
|
|
$rv == -1 ? -1 : 0; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 AUTHOR |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Binary.com, C<< >> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 BUGS |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
213
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
214
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 SUPPORT |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
perldoc ZMQ::LibZMQ2::LibZMQ3 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
You can also look for information at: |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=over 4 |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
L |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
L |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item * CPAN Ratings |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
L |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item * Search CPAN |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
L |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=back |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Copyright 2014 Binary.com. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
This code is released under the Apache License version 2. Please see the |
257
|
|
|
|
|
|
|
included LICENSE file. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head2 TEST SUITE COPYRIGHT AND LICENSE |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
The Test Suite is copied from ZMQ::LibZMQ, is copyright Daisuke Maki |
262
|
|
|
|
|
|
|
and Steffen Mueller, . |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
It is released uner the same terms as Perl itself. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
1; # End of ZMQ::LibZMQ2::LibZMQ3 |