title: System.IO.Stream.Read gets stuck
body: <p>I have an HTTP connection with the server side using System.IO.Stream.Read to read the HTTP request body message.
  The problem is that once in a couple of minutes the server gets stuck on the Read statement and doesn't continue until the socket timeout has been reached or the client has closed the connection.</p>
  
  <pre><code>int bytesRead = 0;
  
  while (bytesRead &lt; contentLength)
  {
    int got = stream.Stream.Read(buffer.Buffer, bytesRead, contentLength - bytesRead);
    bytesRead += got;
  }
  </code></pre>
  
  <ol>
  <li><p>It could happen if the stream did not have the amount of data specified by contentLength variable.
  This is not the case because when following the tcp stream with WireShark I see that the whole message body (as specified by contentLength) has reached the server machine.</p></li>
  <li><p>It happens only in the first time that the while loop has been "used", i.e. only in the first time that the stream didn't have "contentLength" number of bytes to read in one try and the while loop had to be re-entered.</p></li>
  </ol>
  
  <p>Why does it get stuck and does not continue reading data?</p>