[zeromq-dev] automatically choosing a free TCP port

Martin Lucina mato at kotelna.sk
Tue Mar 16 13:43:43 CET 2010

sustrik at 250bpm.com said:
> > 0MQ would get back two records from DNS and try in a round-robin fashion
> > until it can connect to one or the other. Straightforward to debug and not
> > prone to "magic failures" like I mentioned in my other email.
> > 
> > The only downside is you need access to your DNS zone.
> However, the above still requires using _fixed_ ports rather than 
> auto-generating port numbers.

Sure. It's a matter of taste. The moment you want to use dynamic port
numbers you end up with a dependency on some kind of dynamic "registry" of
services, which introduces extra complexity.

Also, dynamic port numbers make it *impossible* to firewall your services
sensibly without doing some kind of stateful inspection of packet content
which doesn't work well in many cases. On the other hand, if I know that my
super-important service communicates on TCP port 12123, I can trivially 
block that specific traffic on my firewall.

Personally I prefer the simpler, less magic, solutions ...


More information about the zeromq-dev mailing list