Hi Mike,

"Alexander, Michael" <[email protected]> writes:

> I have been using zmq_bind(socket, “tcp://lo:*”) to bind to a random
> unused port.  I can find examples using other languages to use
> random_port to limit the range of ports (e.g. only assign a port
> between 30000 and 31000).  Is there a way to do this in C++?

Maybe it's heavy handed, but I do this by manually looping over a port
range, continuing until I no longer get an error from cppzmq's
zmq::socket_t::bind():

  https://github.com/brettviren/zio/blob/master/src/port.cpp#L44

Actually, now I check cppzmq and I'm not sure why I did this because I
see cppzmq simply passes through the address to zmq_bind().  So, if
"tcp://lo:*" works with libzmq, I think it should work with cppzmq.

-Brett.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to