title: A couple questions about NetworkStream.DataAvailable and NetworkStream.Read
body: <p>I'm troubleshooting an application that uses NetworkStream to send data and receive data. I have a couple questions related to NetworkStream.DataAvailable and NetworkStream.Read</p>
  
  <p>Here is code:</p>
  
  <pre><code>    try
      {
       if(DataAvailable)
       {
        numberOfBytesRead = myNetworkStream.Read(myReadBuffer, 0, myReadBuffer.Length);
        myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
       }
  
     catch
       {}
     }
  </code></pre>
  
  <p>The server sends back data in 5 packets every time.</p>
  
  <p>Questions:</p>
  
  <p>Does read method above receive all the packets or only random packets(1-5)? </p>
  
  <p>Does the NetworkStream.DataAvailable reset to False after the data is read? and set to True again if a new packet is arrived(Assume answer for question 1 is random packets)?</p>
  
  <p>Thanks!!!</p>