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

Pieter Hintjens ph at imatix.com
Wed Aug 4 09:37:12 CEST 2010

The message is set to empty when sent, so the second call presumably
succeeds but sends an empty message.


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
> 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/4a8426f1/attachment.htm>

More information about the zeromq-dev mailing list