[zeromq-dev] Socket use from several threads

Chuck Remes lists at chuckremes.com
Wed Jul 18 13:33:58 CEST 2012


On Jul 18, 2012, at 2:49 AM, moteus wrote:

> Chuck Remes <lists <at> chuckremes.com> writes:
> 
> 
>> Oh, so the threads are short-lived then. In that case, you should create a
> pool of them and have each thread
>> "check out" the socket from the pool when it needs to use it and check it back
> in again when the thread exits.
>> If the pool is protected by a mechanism (like a mutex) that employs a full
> memory barrier, then it will be safe.
> 
> Thanks.
> And one more question. 
> Can I start recv in one thread but get result in other?
> For example. I use DEALER socket instead REQ and get timeout on recive.
> I put socket back to pool. Another thread get this socket from pool and send 
> it's own request. This thread can recognize its response and ignore other
> responses. 
> Or better just to recreate socket like described in guide?

I don't know. Try it out and let us know how it works.

cr


More information about the zeromq-dev mailing list