title: Socket Receiving Wrong Data
body: <p>I have server written in C/C++, and the client is in Java which is running on android. </p>
  
  <p>The server look like</p>
  
  <p><strong>C++ server</strong></p>
  
  <pre><code>#define ETH_DATA_LENGTH 25
  
   bzero(buf,ETH_DATA_LENGTH);
   rd=read(newsockfd,buf,ETH_DATA_LENGTH);
  
        if(rd&gt;0){
         printf("received %s\n", buf);
         char cmd[ETH_DATA_LENGTH]={0};
         sprintf(cmd,"%s",buf);
         //setCommand(cmd);
         } 
  </code></pre>
  
  <p>The android client send data packet of format  <code>5_11_14_, 5_11_15_, 5_11_16_,etc...</code> and the server receives the data correctly if there is a delay in client side with in each packet. But when the client send continuously I am getting some extra character and look like </p>
  
  <pre><code>received 5_11_9_
  
  received 5_11_10_
  5_11_11_
  5_11_12�ڳ
  received _
  
  received 5_11_13_
  </code></pre>
  
  <p>And on the android side I am sending the data like</p>
  
  <p><strong>Java client</strong></p>
  
  <pre><code>PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(clientsocket.getOutputStream())),true);
  out.println(str);
  </code></pre>
  
  <p>Any idea why this happening ?</p>
  
  <p>Thanks in advance....</p>