[zeromq-dev] [Fwd: Re: socket call back when using the zmq_loop]

Jon Dyte jon at totient.co.uk
Sat Dec 19 18:11:21 CET 2009

On Friday 18 Dec 2009, Petitdemange Sébastien wrote:

> First thanks a lot for your quick replay.
> In fact what I want to do is more like that:
> zmq::socket_t s1 (ctx, ZMQ_SUB);
> zmq::socket_t s2 (ctx, ZMQ_SUB);
> s1.connect ("tcp://server001:5555");
> s1.setsockopt (ZMQ_SUBSCRIBE, "abc.*", 5);
> s2.connect ("tcp://server002:5555");
> s2.setsockopt (ZMQ_SUBSCRIBE, "def.*", 5);

so you do not want to get def.* messages from server001:5555
nor abc.* messages from  server002:5555

if you have control of the publishing topic space on the ZMQ_PUB
side you could add the source indicator to the topic, say s1 and s2,

then Martin's example would become (caveat, completely untested)

 zmq::socket_t s (ctx, ZMQ_SUB);
s.connect ("tcp://server001:5555");
s.connect ("tcp://server002:5555");
s.setsockopt (ZMQ_SUBSCRIBE, "S1abc.*", 5); // from server 1
s.setsockopt (ZMQ_SUBSCRIBE, "S2def.*", 5); // from server 2

while (true)



More information about the zeromq-dev mailing list