[zeromq-dev] Zyre ipaddress in Hello message
Lindley French
lindleyf at gmail.com
Wed Jan 1 19:27:55 CET 2014
Binding a separate socket to each interface (in fact, binding separately to
IPv6 and IPv4 addresses) has worked well for me in the past. Then just
select() on all of them.
On Wed, Jan 1, 2014 at 10:15 AM, Pieter Hintjens <ph at imatix.com> wrote:
> Looking at this, it's non-trivial. Here's more explanation and sample
> code:
> http://bert-hubert.blogspot.fr/2012/10/on-binding-datagram-udp-sockets-to-any.html
>
> I'm thinking that we could make a portable alternative, which is to
> create multiple UDP sockets, one for each interface. Rather than bind
> to INADDR_ANY, we could bind each socket to a specific interface, and
> then it's easy to get the ipaddress for each socket. It's easy to poll
> on multiple sockets.
>
> Thoughts?
>
> -Pieter
>
>
>
> On Wed, Jan 1, 2014 at 4:01 PM, Pieter Hintjens <ph at imatix.com> wrote:
> > On Sat, Dec 28, 2013 at 11:25 AM, Arnaud Loonstra <arnaud at sphaero.org>
> wrote:
> >
> >> Because zbeacon passes the ipaddress on to the agent which the zyre_node
> >> uses...
> >
> > Right... HELLO message isn't the beacon, my mistake. The node will
> > connect using the HELLO's ipaddress only if it didn't already get a
> > beacon from that node.
> >
> > You're right that the ipaddress will be wrong in cases with multiple
> > interfaces. This could be improved... right now the Zyre internals
> > just don't allow for that. It should pick-up the hostname dynamically
> > each time it sends HELLO.
> >
> > Alternatively, as you say, it could get the originating IP address of
> > each HELLO message. That is more work. The libzmq API doesn't provide
> > that directly (we could extract it at authentication time, from
> > ZMQ/4.0 and later).
> >
> > So option 1 then. The flow is, A gets beacon from B, and then connects
> > to B and sends HELLO. B receives HELLO from A, and connects back to A.
> > So A knows what address it received a beacon on.
> >
> > It seems we need to use recvmsg() instead of recvfrom(). There's an
> > example here:
> >
> >
> http://stackoverflow.com/questions/5281409/get-destination-address-of-a-received-udp-packet
> >
> > So then, zbeacon would update its hostname property after each recv,
> > and the caller could use this to construct an accurate HELLO message.
> >
> > -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140101/1c728747/attachment.htm>
More information about the zeromq-dev
mailing list