ZeroMQ - A ZeroMQ2 wrapper for Perl
use ZeroMQ qw/:all/; my $cxt = ZeroMQ::Context->new; my $sock = ZeroMQ::Socket->new($cxt, ZMQ_REP); $sock->bind($addr); my $msg; foreach (1..$roundtrip_count) { $msg = $sock->recv(); die "Bad size" if $msg->size() != $msg_size; $sock->send($msg); }
See the xt/ directory for full examples.
The ZeroMQ module is a wrapper of the 0MQ message passing library for Perl. It's a thin wrapper around the C++ API.
ZeroMQ
Loading ZeroMQ will make the ZeroMQ::Context, ZeroMQ::Socket, and ZeroMQ::Message classes available as well.
You may choose to import one or more (using the :all import tag) constants into your namespace by supplying arguments to the use ZeroMQ call as shown in the synopsis above.
:all
use ZeroMQ
The exportable constants are:
Socket types
ZMQ_REQ ZMQ_REP ZMQ_PUB ZMQ_SUB ZMQ_DOWNSTREAM ZMQ_UPSTREAM ZMQ_PAIR
Socket recv flags
ZMQ_NOBLOCK
get/setsockopt options
ZMQ_RCVMORE ZMQ_HWM ZMQ_SWAP ZMQ_AFFINITY ZMQ_IDENTITY ZMQ_RATE ZMQ_RECOVERY_IVL ZMQ_MCAST_LOOP ZMQ_SNDBUF ZMQ_RCVBUF ZMQ_SUBSCRIBE ZMQ_UNSUBSCRIBE
This is an early release. Proceed with caution, please report (or better yet: fix) bugs you encounter. Tested againt 0MQ 2.0.7.
Use of the inproc:// transport layer doesn't seem to work between two perl ithreads. This may be due to the fact that right now, context aren't shared between ithreads and inproc works only within a single context. Try another transport layer until contexts can be shared.
inproc://
inproc
ZeroMQ::Context, ZeroMQ::Socket, ZeroMQ::Message
http://zeromq.org
ExtUtils::XSpp, Module::Build::WithXSpp
Steffen Mueller, <smueller@cpan.org>
The ZeroMQ module is
Copyright (C) 2010 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.
To install ZeroMQ, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZeroMQ
CPAN shell
perl -MCPAN -e shell install ZeroMQ
For more information on module installation, please visit the detailed CPAN module installation guide.