[zeromq-dev] Some questions about ZMQ PUB/SUB usage

Martin Sustrik sustrik at 250bpm.com
Mon Aug 22 13:02:24 CEST 2011

Hi Emmanuel,

> The process receiving the data open only one SUB socket. This process
> consistently gets data from one publisher and for some period of
> time from other publisher(s). To get data coming from these "transient"
> publisher, I simply call connect on the SUB socket with their endpoint.
> Its seems to work fine. Nevertheless, I am doing this from another
> thread than the thread where the socket is created and run.
> My first question is: is it safe to do so?

No. It's not. Sockets are not thread safe.

> My second question is what about disconnection. I don't know how I can
> disconnect my socket from the "transient" publisher.
> Is there a way to do this kind of thing?

Connect the other way round. Bind the SUB socket and connct the 
transient PUB sockets.


More information about the zeromq-dev mailing list