title: reading buffer from socket
body: <p>I'm writing simple server/client in c, where server temporary stores message from client and retrieve it when client request it.</p>
  
  <p>The problem is when client receives message from server, the buffer acts kinda weird.
  All i did is read as much as receive from server and print it on the screen, but somehow buffer was overwrited more than maximum size of buffer</p>
  
  <p>in client </p>
  
  <pre><code>while((byteRead = recv(ssock, buffer, MAXBUF, 0)) &gt; 0)
  {
     if(byteRead &lt;= 0)
         break;
      printf("%s", buffer);
  }
  </code></pre>
  
  <p>where MAXBUF is 256. It keep contains some garbages so i examined the string size in buffer
  and surprisingly </p>
  
  <pre><code>printf("%d READ vs %d buffer strlen \n", byteRead, strlen(buffer))
  </code></pre>
  
  <p>show me that byteRead is 256 but string length of buffer is 262.</p>
  
  <p>Any idea??</p>
  
  <p>P.s on server side, it reads file correctly and send it onto socket.</p>