[zeromq-dev] Ephemeral / dynamic ports in CZMQ

Pieter Hintjens ph at imatix.com
Thu Jun 9 14:54:46 CEST 2011


Hi all,

I've added a feature to CZMQ that we could standardize across other
language bindings, and eventually get into libzmq.

If you bind to an interface and specify '*' as the port, it'll look
for an available port in the range 0xc000 - 0xffff, which is specified
by IANA for dynamic or private ports. The zsocket_bind() method then
returns the actual port number used, which can be communicated to
other 0MQ peers.

An example of use:

    int port = zsocket_bind (my_socket, "tcp://*:*");

-Pieter

[1] https://github.com/zeromq/czmq/blob/master/src/zsocket.c



More information about the zeromq-dev mailing list