[zeromq-dev] Binding to TCP port 0

Pieter Hintjens ph at imatix.com
Thu Jan 26 17:39:47 CET 2012


On Thu, Jan 26, 2012 at 8:34 AM, AJ Lewis <aj.lewis at quantum.com> wrote:

> Forgive me if I'm being dense, but couldn't the N case work if you made
> sure to do the getsockopt() call after each zmq_bind()?
>
> zmq_bind(foo, "tcp://XXXX:0")
> zmq_getsockopt(foo, GET_LAST_BOUND_PORT, &port1, sizeof(port1))
> zmq_bind(foo, "tcp://YYYY:0")
> zmq_getsockopt(foo, GET_LAST_BOUND_PORT, &port2, sizeof(port2))

You're not being dense and this is exactly what I meant by "bind is
synchronous", unlike a connect. The code example makes it easier to
understand. Thanks!

-Pieter



More information about the zeromq-dev mailing list