[zeromq-dev] multi io thread sync problem
Ian Barber
ian.barber at gmail.com
Mon Aug 1 14:43:19 CEST 2011
On Mon, Aug 1, 2011 at 1:37 PM, kaka chen <kaka11.chen at gmail.com> wrote:
> Hi all:
>
>>
>> I read the source code of zeromq, but I don't know how to guarantee
>> message sending/recving sync when using multi io thread. For example, if
>> one thread recv a part of message, and then another thread recv this
>> message and can not process this message correctly. so I think it should
>> use a sync facility likes 'leader/followers' to prevent this problem.
>>
>> Kaka Chen
>
>
Hi Kaka,
Multiple threads can't share a socket, so you shouldn't run into a problem
here. If you receive a part, you can check the ZMQ_RCVMORE sockopt flag to
see whether there are any more parts - you are guaranteed to get an entire
message without parts from other messages being interleaved until that flag
returns 0.
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110801/415b3249/attachment.htm>
More information about the zeromq-dev
mailing list