This is how I read the input stream
while (!stopRequested && stream.CanRead)
{
byte[] buffer = new byte[READ_BUFFER_SIZE];
Int32 bytesRead = stream.Read(buffer, 0, READ_BUFFER_SIZE);
byte[] response = new byte[bytesRead];
Array.Copy(buffer, response, bytesRead);
responsesStream.AddRange(response); //push the bytes onto the dataStream
ParseStream(responsesStream); //attempt to parse
}
How do you implement an efficient binary protocol parser given that you have a spec like in following example
Concise code samples or links highly appreciated. thx