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

Matt Weinstein matt_weinstein at yahoo.com
Wed Aug 4 14:38:59 CEST 2010


Send returns 0 on success ( for me )

Got a code sample?



On Aug 4, 2010, at 4:06 AM, Michael Small <michaelsmall at me.com> wrote:

> That sounds like a reasonable assumption. I think it's time to delve into the source and have a look at how all this works.
> 
> Thanks guys
> 
> On 04/08/2010, at 5:37 PM, Pieter Hintjens wrote:
> 
>> The message is set to empty when sent, so the second call presumably succeeds but sends an empty message.
>> 
>> -Pieter
>> On Aug 4, 2010 6:02 AM, "Michael Small" <michaelsmall at me.com> wrote:
>> > 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
>> > 
>> 
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> 
> _______________________________________________
> 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/87d78a74/attachment.htm>


More information about the zeromq-dev mailing list