[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:51:35 CEST 2014
Correction: I do use the same ports when testing (so both 55555 or 54321)
On Tue, Sep 9, 2014 at 3:48 PM, Gerrit Hendrikus van Doorn <
g.h.vandoorn at gmail.com> wrote:
> 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?
>
>
>
>
>
>
--
g.h.vandoorn at gmail.com
+1.510.859.4618
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140909/523c2737/attachment.htm>
More information about the zeromq-dev
mailing list