[zeromq-dev] Dropping connection end points dynamically

Chuck Remes lists at chuckremes.com
Thu Apr 19 14:19:00 CEST 2012


On Apr 18, 2012, at 5:09 PM, Radha Krishna Srimanthula wrote:

> Can you please help me with my first qn?
> 
> Just to restate - would it be ok to create a socket in a main thread - only once, perform subscriptions/ unsubscriptions in another, and perform sends on the yet another thread?

Use a mutex to protect the sockets. The main problem is that sockets aren't thread safe, so if you make any calls on them simultaneously from those 3 threads, bad things will eventually happen. If you use a mutex to guarantee that only one thread is accessing a particular socket at a time, then you will be safe.

cr




More information about the zeromq-dev mailing list