[zeromq-dev] Only receive a single published message per connection?

Michael Small michaelsmall at me.com
Wed Aug 4 06:01:38 CEST 2010


Ah, I see.

So creating another message entirely does the trick and I'm seeing multiple messages received now.
However it leaves me a bit curious because the result of s.send(msg) in both cases was 1.

[m] s.send(msg_1): 1, data: fsm.t|This is a test (fsmd.cpp:50 in main) I
[m] s.send(msg_2): 1, data: fsm.p|This is a test (fsmd.cpp:52 in main) I
[m] s.send(msg_3): 1, data: fsm.t|This is a test (fsmd.cpp:54 in main) I

According to the manual "The zmq_send() function shall return zero if successful. Otherwise it shall return -1" so the manual is incorrect perhaps?

On 04/08/2010, at 1:48 PM, Chuck Remes wrote:

> On Aug 3, 2010, at 10:33 PM, Michael Small wrote:
> 
>> I've observed strange behaviour in my initial testing of pub/sub.
>> 
>> The relevant subscriber code:
>> 
>> while(s.recv(&msg)) {
>>           printf("Received: %s\n", (char*)msg.data());
>>       }
>> 
>> And the publish code:
>> 
>> s.send(msg);
>> s.send(msg);
>> getchar();
>> 
>> The first message is received, but the second is not. If I kill the publisher and restart (leaving the subscriber active), again the first message is received, but not the second.
>> Is there some semantic of this pattern that I'm not aware of?
>> 
>> This is being tested on an OS X 10.6.4 box.
> 
> As soon as you hand off a message to 0mq, it becomes the owner of the message lifecycle. Under the covers that "msg" is released, so the second send is very likely not succeeding due to the message no longer existing. You should check the return codes of each send to be sure.
> 
> cr
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100804/25fa575f/attachment.htm>


More information about the zeromq-dev mailing list