title: ZMQ recv randomly picks up garbage data does any one know why?
body: <p>I have a client server app which is sending data from a C# client to a C++ server.  When the server receives this data request, 9 out of 10 times it works ok, but there is always 1 time were there will be garbage data appended to the end of the received data on the server side.</p>
  
  <p>for example instead of receiving a number 1 it will receive 1C or 1@???? </p>
  
  <p>Here are snippets of the client and server code, any help will be appreciated.</p>
  
  <p>C# client</p>
  
  <pre><code>int flagSide = 1;
  
  msg = name;
  msg += "+";
  msg += "qty";
  msg += "+";
  msg += flagSide.ToString();
  
  ZeroMQ.ZmqContext context = ZeroMQ.ZmqContext.Create();
  
  ZeroMQ.ZmqSocket socket = context.CreateSocket(SocketType.REQ);
  
  socket.Connect("tcp://111.111.0.111:5556");
  
  socket.Send(Encoding.ASCII.GetBytes(msg.ToCharArray()));
  
  Thread.Sleep(1);
  
  string reply = socket.Receive(Encoding.ASCII);
  
  Console.WriteLine("Received reply = " + reply + "\n"); 
  </code></pre>
  
  <p>C++ Server </p>
  
  <pre><code>std::tr1::unordered_map &lt;std::string, std::string&gt; aMap;
  
  zmq::context_t context( 1 );
  zmq::socket_t responder( context, ZMQ_REP ); 
  
  responder.bind ("tcp://*:5556");
  
  while ( 1 )
  {
  zmq::message_t recvMsg;
  responder.recv( &amp;recvMsg );
  
  t = static_cast&lt;char*&gt;( recvMsg.data() );
  
  std::string s(t);
  
  std::vector&lt;std::string&gt; strs;
  
  boost::split(strs, s, boost::is_any_of("+"));
  
  aMap["name"] = strs[0];
  aMap["qty"] = strs[1];
  aMap["flag"] = strs[2];
  
  
  ..........
  </code></pre>
  
  <p>outputing the split string in the server reveals that sometimes the flag or strs[2] receives the garbage data.</p>
  
  <p>Please help me if you see something that I'm not seeing.</p>
  
  <p>Thanks</p>