[zeromq-dev] Send and receive using link-local IPv6 address using zmq 3.2.3 and czmq 1.4.1
Gerrit Hendrikus van Doorn
g.h.vandoorn at gmail.com
Wed Sep 10 00:48:51 CEST 2014
Hi,
I'm trying to use PUSH/PULL sockets over an IPv6 link-local address (on the
same machine). I wrote 2 small test applications to test which address
formats work, one pushing a string and the other receiving it. However, I
have not been able to get it to work using the link-local address.
// ======== zmq_server ========
#include <iostream>
#include <czmq.h>
int main(int argc, char **argv) {
if (argc != 2) {
std::cout << "USAGE: prog tcp://localhost:12345" << std::endl;
return -1;
}
std::cout << "Binding to " << argv[1] << std::endl;
zctx_t *ctx = zctx_new ();
auto writer = zsocket_new (ctx, ZMQ_PUSH);
zsocket_set_ipv4only(writer, 0);
int rc = zsocket_bind(writer, argv[1]);
if (rc == -1) {
std::cout << "Unable to bind to " << argv[1] << std::endl;
return -1;
}
while (rc != -1) {
rc = zstr_send(writer, "HELLO");
}
zsocket_destroy (ctx, writer);
zctx_destroy (&ctx);
return 0;
}
// ======== zmq_client ========
#include <iostream>
#include <czmq.h>
int main(int argc, char **argv) {
if (argc != 2) {
std::cout << "USAGE: prog tcp://localhost:12345" << std::endl;
return -1;
}
std::cout << "Connecting to " << argv[1] << std::endl;
zctx_t *ctx = zctx_new();
auto reader = zsocket_new(ctx, ZMQ_PULL);
zsocket_set_ipv4only(reader, 0);
int rc = zsocket_connect(reader, argv[1]);
if (rc == -1) {
std::cout << "Unable to connect to " << argv[1] << std::endl;
std::cout << zmq_strerror(zmq_errno()) << std::endl;
return -1;
}
while (rc != -1) {
auto str = zstr_recv(reader);
if (str == nullptr) {
return 0;
}
std::cout << "Received: " << str << std::endl;
}
zsocket_destroy(ctx, reader);
zctx_destroy(&ctx);
return 0;
}
Usage (note the escaped % sign as czmq uses printf):
./zmq_server tcp://[::1]:54321
./zmq_client tcp://[fe80::a2d3:c1ff:fe04:9f60%%eth0]:55555
The server and client never connect or receive data. They work fine using
IPv4.
The applications run on the same machine (which has multiple interfaces).
I'm using zmq 3.2.3 and czmq 1.4.1.
Any thoughts on what I'm doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140909/9aa31246/attachment.htm>
More information about the zeromq-dev
mailing list