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
Here is code:
try
{
if(DataAvailable)
{
numberOfBytesRead = myNetworkStream.Read(myReadBuffer, 0, myReadBuffer.Length);
myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
}
catch
{}
}
The server sends back data in 5 packets every time.
Questions:
Does read method above receive all the packets or only random packets(1-5)?
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)?
Thanks!!!