[zeromq-dev] Can't bind same ZMQ_UP/DOWNSTREAM multiple times.

Oliver Smith oliver at kfs.org
Sat Aug 21 08:36:53 CEST 2010

  On 8/19/2010 5:10 PM, Jon Dyte wrote:
> does this do what you want
Yes :) Perfectly, thank you.

It still seems like a duplication of work resulting from an artificial 
imposition of an unrelated networking constraint.

That is: because the networking concept of bind and connect, server and 
client are being strictly enforced, you need an /additional worker/ (the 
device) to bridge two communications channels that are only separated by 
that imaginary concept.

If the zmq_contexts were to ALWAYS take ownership of bound sockets and 
then quietly join binders to them, then you could always have multiple 
binds to an address regardless of protocol. You would, of course, not be 
able to bind the same address across different contexts, but that then 
begins to make sense.

     ctx1 = zmq.Context(1)
     ctx2 = zmq.Context(2)

     s11, s12, s21 = ctx1.socket(zmq.DOWNSTREAM), 
ctx1.socket(zmq.DOWNSTREAM), ctx2.socket(zmq.DOWNSTREAM)
     addr = "inproc://address"
     s11.bind(addr)    # ctx1 now owns the address.
     s12.bind(addr)    # OK: Context owns the address.
     s21.bind(addr)    # FAIL: Address already in use.

More information about the zeromq-dev mailing list