The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

AnyEvent::Handle::ZeroMQ - Integrate AnyEvent and ZeroMQ with AnyEvent::Handle like ways.

VERSION

Version 0.09

SYNOPSIS

    use AnyEvent::Handle::ZeroMQ;
    use AE;
    use ZeroMQ;

    my $ctx = ZeroMQ::Context->new;
    my $socket = $ctx->socket(ZMQ_XREP);
    $socket->bind('tcp://0:8888');

    my $hdl = AnyEvent::Handle::ZeroMQ->new(
        socket => $socket,
        on_drain => sub { print "the write queue is empty\n" },
        on_error => sub { my($error_msg) = @_; ... },
            # catch errors when occured in the reading callback
    );
    # or $hdl->on_drain( sub { ... } );
    # or $hdl->on_error( sub { ... } );
    $hdl->push_read( sub {
        my($hdl, $data) = @_;

        my @out;
        while( defined( my $msg = shift @$data ) ) {
            push @out, $msg;
            last if $msg->size == 0;
        }
        while( my $msg = shift @$data ) {
            print "get: ",$msg->data,$/;
        }
        push @out, "get!";
        $hdl->push_write(\@out);
    } );

    AE::cv->recv;

METHODS

new( socket => $zmq_socket, on_drain(optional) => cb(hdl) )

push_read( cb(hdl, data (array_ref) ) )

push_write( data (array_ref) )

old_cb = on_drain( cb(hdl) )

old_cb = on_error( cb(hdl) )

DIFFERENCES

There is also a module called AnyEvent::ZeroMQ in CPAN.

AnyEvent::ZeroMQ::* is a huge, heavy, and full-functioned framework, but this module is a simple, lightweight library with less dependency, and runs faster.

So this module is only occupy a smaller namespace under AnyEvent::Handle::

This module and AnyEvent::ZeroMQ::* are not replacable to each other.

AUTHOR

Cindy Wang (CindyLinz)

BUGS

Please report any bugs or feature requests to bug-anyevent-handle-zeromq at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-Handle-ZeroMQ. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc AnyEvent::Handle::ZeroMQ

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Cindy Wang (CindyLinz).

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.