[zeromq-dev] publish dynamic port
Luca Boccassi
luca.boccassi at gmail.com
Mon Jun 26 13:03:24 CEST 2017
On Mon, 2017-06-26 at 11:38 +0300, Mos Yud wrote:
> Hi,
>
> I am using zmq- 4.2.1.
>
> I would like to establish P2P connection (client-server). Server bind
> to a
> dynamic port and client should be familiar with the port number in
> order to
> connect to it.
> What is best way to publish the port number to the client?
>
> Thx.
> Moshe.
Zyre can be used for autodiscovery and forming groups:
https://github.com/zeromq/zyre
If over the same LAN then the default will work with broadcast,
otherwise you'll need a well-known "hub" in gossip mode.
Alternatively if what you need is a small range of dynamic ports for
the server, then you can use CZMQ which supports that:
zsock_bind(sock, "tcp://127.0.0.1:![55000-55009]")
This will bind to the first free port in that range. Then your client
can connect to the whole range, and the one that succeeds will be
automatically used. Of course if the range is large then it becomes
very inconvenient.
Kind regards,
Luca Boccassi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20170626/d48bb85a/attachment.sig>
More information about the zeromq-dev
mailing list