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

Emmanuel TAUREL taurel at esrf.fr
Mon Aug 22 13:11:30 CEST 2011


Thanks very much for your very fast answer.

On 22/08/2011 13:02, Martin Sustrik wrote:
> 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.

Even with full memory fence before using the socket to connect it to the 
transient PUB in the second thread?
I think I have once read this advice in the mailing list.

>> 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.

I am sorry but I do not really get the point here. I had in mind that 
only the PUB socket binds and the SUB socket connects.
This is not true?


More information about the zeromq-dev mailing list