[nanomsg] Messages get lost using the pub/sub model

  • From: 李捷 <lijielile@xxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Sun, 5 Jun 2016 14:40:49 -0400

I am planning to use the pub/sub model to broadcast messages from one
thread to multiple threads.  However, after playing around with it I found
when broadcasting messages from the server node to the client nodes, the
first messages can't be received. If I sent two messages from the server,
only the second one is received and if I send three, the last two got
received. If I only send one message, the receiving node block for ever
waiting for the messages. Did I miss anything? Also, by looking at the
sample from the tutorial, it is obvious that messages got lost too.  Below
is copied from the tutorial page. Obviously 6 messages were sent and only 4
were received?

gcc pubsub.c /usr/local/lib/libnanomsg.a -o pubsub./pubsub server
ipc:///tmp/pubsub.ipc & server=$! && sleep 1./pubsub client
ipc:///tmp/pubsub.ipc client0 & client0=$!./pubsub client
ipc:///tmp/pubsub.ipc client1 & client1=$!./pubsub client
ipc:///tmp/pubsub.ipc client2 & client2=$!sleep 5kill $server $client0
$client1 $client2

SERVER: PUBLISHING DATE Sat Sep  7 17:40:11 2013
SERVER: PUBLISHING DATE Sat Sep  7 17:40:12 2013
SERVER: PUBLISHING DATE Sat Sep  7 17:40:13 2013
CLIENT (client2): RECEIVED Sat Sep  7 17:40:13 2013
CLIENT (client0): RECEIVED Sat Sep  7 17:40:13 2013
CLIENT (client1): RECEIVED Sat Sep  7 17:40:13 2013
SERVER: PUBLISHING DATE Sat Sep  7 17:40:14 2013
CLIENT (client2): RECEIVED Sat Sep  7 17:40:14 2013
CLIENT (client1): RECEIVED Sat Sep  7 17:40:14 2013
CLIENT (client0): RECEIVED Sat Sep  7 17:40:14 2013
SERVER: PUBLISHING DATE Sat Sep  7 17:40:15 2013
CLIENT (client1): RECEIVED Sat Sep  7 17:40:15 2013
CLIENT (client2): RECEIVED Sat Sep  7 17:40:15 2013
CLIENT (client0): RECEIVED Sat Sep  7 17:40:15 2013
SERVER: PUBLISHING DATE Sat Sep  7 17:40:16 2013
CLIENT (client1): RECEIVED Sat Sep  7 17:40:16 2013
CLIENT (client2): RECEIVED Sat Sep  7 17:40:16 2013
CLIENT (client0): RECEIVED Sat Sep  7 17:40:16 2013

Other related posts: