[zeromq-dev] q: how to announce a DSN when using "tcp://*:*"

Michael Haberler mail17 at mah.priv.at
Fri May 9 15:19:00 CEST 2014


I'm using DNS-SD for service discovery, and would like to bind sockets like tcp://*:* - i.e. all interfaces, and choose an ephemeral port

it would be nice if the DSN retrieved from the ZMQ_LAST_ENDPOINT could be used for this; however, int the case of tcp://*:* (i.e INADDR_ANY) that comes out as 'tcp://0.0.0.0:<ephemeral port>', and that is not something which can be announced as an endpoint.

I have a workaround but it's a bit kludgy: specify a preference list of interfaces/interface patterns (eg pref='eth wlan usb') and pick an interface that is up, matches the list, and has a suitable IP address; then bind to 'tcp://<interface>:*' . In that case  ZMQ_LAST_ENDPOINT gives me a  connectable DSN, and that I announce via DNS-SD. But it means just one IP address is bound, and announced.

An alternative is to drop the concept of a URI being announced, and just use the hostname and port number from the DNS-SD announcement; the client constructs a URI from host and port, and connects. That assumes the host being announced is among the IP addresses bound to by zmq_bind(), and that IP address is routable (i.e. not a private non-routed address space). I might not fully understand the way avahi works and if that is actually a problem.

I'd be interested in suggestions how to deal with this

thanks in advance

- Michael





More information about the zeromq-dev mailing list