[zeromq-dev] ZMQx::Class - a more Perlish interface to ZeroMQ

Pieter Hintjens ph at imatix.com
Mon Oct 7 10:14:53 CEST 2013


Hi Thomas (Dylan too),

You can update the Perl binding page to include your project, or
create a new page for it on the wiki. http://zeromq.org/bindings:perl

-Pieter

On Mon, Oct 7, 2013 at 9:29 AM, Thomas Klausner <domm at plix.at> wrote:
> Hi!
>
> Sort of in reaction to Dylan Calis post about ZMQ::FFI I'm finally
> announcing our high-level ZeroMQ Perl wrapper:
>
> https://metacpan.org/module/ZMQx::Class
> https://github.com/domm/ZMQx-Class
>
> It's using ZMQ::LibZMQ3 and Moose, key features are:
> * Easy setup of sockets
> * Easy setting & getting of sockopts
> * Easy sending & receiving of single- and multipart messages
> * Fork / Context handling
> * AnyEvent helpers
>
>
> Here's an example publisher:
>
> use ZMQx::Class;
> use Time::HiRes qw(usleep);
>
> my $publisher = ZMQx::Class->socket( 'PUB', bind => 'tcp://*:10000' );
>
> while ( 1 ) {
>     my $random = int( rand ( 10_000 ) );
>     say "sending $random hello";
>     $publisher->send( [ $random, 'hello' ] );
>     usleep(1000);
> }
>
>
> and here a matching subscriber:
>
>
> use ZMQx::Class;
> use Anyevent;
>
> my $subscriber = ZMQx::Class->socket( 'SUB', connect => 'tcp://localhost:10000' );
> $subscriber->subscribe( '1' );
>
> my $watcher = $subscriber->anyevent_watcher( sub {
>     while ( my $msg = $subscriber->receive ) {
>         say "got $msg->[0] saying $msg->[1]";
>     }
> });
> AnyEvent->condvar->recv;
>
>
> Any Feedback is welcome!
>
> Greetings,
> domm
>
>
> --
> #!/usr/bin/perl                              http://domm.plix.at
> for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list