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

Martin Sustrik sustrik at 250bpm.com
Mon Aug 22 13:14:43 CEST 2011


On 08/22/2011 01:11 PM, Emmanuel TAUREL wrote:

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

Yes. You can place the socket into critical section or something. 
Obviously, excessive locking is going to have negative impact on 
performance.

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

There's no correlation between socket type and whether it binds or 
connects. You can do both. Even mix the two.

Martin



More information about the zeromq-dev mailing list