How to properly handle incoming protobuf message with a NetworkStream?
问题 Using TCPClient's NetworkStream and protobuf-net I send and receive protobuf messages via TCP. Receiving is done with the following method that runs in an own thread: private void HandleClientComm() { using (NetworkStream stream = m_Stream) { object o; while (true) { if (stream.CanRead && stream.DataAvailable) { o = null; if (Serializer.NonGeneric.TryDeserializeWithLengthPrefix(stream, PrefixStyle.Base128, Utilities.CommunicationHelper.resolver, out o)) { if (o != null) { //Do something with