[nanomsg] Pub/Sub with IPv6 on a Mac

  • From: Aaron Hillegass <aaron@xxxxxxxxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Fri, 11 Oct 2013 22:41:02 -0400

I've been working at getting a Pub/Sub system working where a subscriber finds 
the publisher via Bonjour.  Bonjour is returning an IPv6 address.  This seems 
to be causing trouble on nanomsg 0.2.  At the moment, I'm running the publisher 
and subscriber on the same machine -- so it is a IPv6 loopback address.

Here's the code stripped down (trimmed out the error checking -- all but the 
nn_bind are successful)

    int sock = nn_socket (AF_SP, NN_SUB);
    int okWithV6 = 0;
    nn_setsockopt(sock, NN_SOL_SOCKET, NN_IPV4ONLY, &okWithV6, sizeof 
(okWithV6));
    nn_setsockopt(sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0);
    int endpoint = nn_bind(sock, "tcp://fe80::1:9876");

I get this error:
        Can't assign requested address [49] (src/transports/tcp/btcp.c:382)

Here is the interesting part of the backtrace:
    frame #2: 0x00007fff967b3bba libsystem_c.dylib`abort + 125
    frame #3: 0x000000010000a8d9 BigWatch`nn_err_abort + 9 at err.c:33
    frame #4: 0x0000000100018133 BigWatch`nn_btcp_handler [inlined] 
nn_btcp_start_listening + 1283 at btcp.c:363
    frame #5: 0x0000000100017fb6 BigWatch`nn_btcp_handler(self=<unavailable>, 
src=<unavailable>, type=<unavailable>, srcptr=<unavailable>) + 902 at btcp.c:266
    frame #6: 0x00000001000067ad BigWatch`nn_fsm_start(self=0x000000010030bcd0) 
+ 45 at fsm.c:113
    frame #7: 0x0000000100017b80 BigWatch`nn_btcp_create(hint=<unavailable>, 
epbase=0x0000000100309b40) + 352 at btcp.c:157
    frame #8: 0x0000000100003225 BigWatch`nn_ep_init(self=0x0000000100309ae0, 
src=<unavailable>, sock=<unavailable>, eid=<unavailable>, 
transport=0x0000000100026328, bind=1, addr=<unavailable>) + 149 at ep.c:74
    frame #9: 0x0000000100005e87 
BigWatch`nn_sock_add_ep(self=0x000000010030b670, transport=<unavailable>, 
bind=<unavailable>, addr=0x00006080000adb96) + 87 at sock.c:433
    frame #10: 0x0000000100004155 BigWatch`nn_global_create_ep(s=0, 
addr=0x00006080000adb96, bind=1) + 325 at global.c:806
    frame #11: 0x0000000100003fe6 BigWatch`nn_bind(s=<unavailable>, 
addr=<unavailable>) + 38 at global.c:450
    frame #12: 0x000000010000300e BigWatch`-[NanomsgReceiver 
waitInBackgroundForURL:dataHandler:](self=0x000060800005a400, 
_cmd=0x000000010001a636, urlString=0x0000608000057f70, 
block=0x00007fff5fbfcc08) + 206 at NanomsgReceiver.m:68

Am I doing something wrong? I'd really appreciate any help I can get.

On the publish side, I'd really like to be publishing on all interfaces, but 
this doesn't seem to be a legit URL:

    int sock = nn_socket (AF_SP, NN_PUB);
    int endpoint = nn_connect(sock, "tcp://*:9876");

Do I really need to specify the interface? (Like this "tcp://en1:9876")

--

Aaron Hillegass
Big Nerd Ranch, LLC.

Other related posts: