[zeromq-dev] push/pull and multiple workers

Chuck Remes lists at chuckremes.com
Fri Aug 17 14:53:12 CEST 2012

On Aug 17, 2012, at 7:32 AM, andrea crotti wrote:

> > You must match a connect with a bind. You cannot have 2 (or more) sockets use zmq_connect to connect to each other. The socket(s) must have something to connect *to* and that is only true when a socket has bound an address. Again, this is just like regular sockets.
> >
> > cr
> >
> >
> Thanks,
> and now suppose that my system only has one publisher and many subscribers, but sometimes I need to add a second publisher,
> is it the moment I need to learn how to use router/dealers right?
> I tried the stupid solution of connecting the second one instead of binding but it's clearly not the solution..

In that situation then you want to use a forwarder device. The forwarder device binds to an incoming and an outgoing port. The publisher(s) connect to the incoming port and the subscriber(s) connect to the outgoing port of the device.

All messages flow through the device to the subscribers. By using the intermediate device, the subscribers do *not* need to know about every possible publisher. It's a very neat and tidy solution.


More information about the zeromq-dev mailing list