You cannot bind multiple sockets to the same address on the same computer, be it ipc or tcp, SUB / PUB or REQ / REP. This is similar to network socket binding.
The way to send messages to all subscribers from many publishers is to implement a simple broker that communicates with the SUB address and PUB address. Publishers connect to the SUB socket to send messages, and subscribers connect to the PUB socket of the same broker, and the broker simply redirects all messages received from the SUB socket to the PUB socket. This requires some performance, but is fairly easy to program.
In ZeroMQ 2.0, you can use the executable zmq_forwarder for this purpose, in 2.1 see the zmq_device (3) function.
source share