[zeromq-dev] Only receive a single published message per connection?
Chuck Remes
cremes.devlist at mac.com
Wed Aug 4 05:48:11 CEST 2010
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
More information about the zeromq-dev
mailing list