Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ZMQ::call for connecting insock <=> outsock as a QUEUE fails. #42

Open
omani opened this issue Oct 8, 2013 · 3 comments
Open

Comments

@omani
Copy link

omani commented Oct 8, 2013

#!/usr/bin/env perl

BEGIN {
    $ENV { PERL_ZMQ_BACKEND } = 'ZMQ::LibZMQ2';
}

use strict;
use warnings;

use ZMQ;
use ZMQ::Constants qw(ZMQ_DEALER ZMQ_ROUTER ZMQ_QUEUE);

my $context = ZMQ::Context->new();

my $frontend = $context->socket(ZMQ_ROUTER);
$frontend->bind('tcp://*:5559');

my $backend = $context->socket(ZMQ_DEALER);
$backend->bind('tcp://*:5560');

ZMQ::call('zmq_device', ZMQ_QUEUE, $frontend, $backend);
OUTPUT:

ZMQ::LibZMQ2::Socket: Invalid ZMQ::LibZMQ2::Socket object was passed to mg_find at queue.pl line 20.

@omani
Copy link
Author

omani commented Oct 8, 2013

Same for:

BEGIN {
    $ENV { PERL_ZMQ_BACKEND } = 'ZMQ::LibZMQ3';
}

@lestrrat
Copy link
Collaborator

that's because ZMQ.pm's ->socket() returns a ZMQ::Socket, but the underlying ZMQ::LibZMQ[23]::zmq_device is expecting a ZMQ::LibZMQ[23]::Socket.

Now having said that it's true that in the current code I don't see a way around it. I don't know which is best: Add a ZMQ::device() (but I believe zmq_device() has rumors about being deprecated...), or just provider ZMQ::Socket::raw_socket() or something so you can do

 ZMQ::call("zmq_device", $frontend->raw_socket(), $backend->raw_socket());

@omani
Copy link
Author

omani commented Oct 10, 2013

right, zmq_device is deprecated: https://github.com/zeromq/libzmq/blob/master/NEWS#L240
zmq_proxy() is to be used instead.
Whatever you find is the easier or best solution to this. ZMQ::Socket::raw_socket() which returns a ZMQ::LibZMQ2::Socket is maybe a good idea.
But there is also the option to provide ZMQ::proxy() directly.
Both are calls to the underlying libzmq[23].

I would love to see this in ZMQ, because right now I rewrote to ZMQ::LibZMQ* because of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants