title: why is this throwing a end of stream encountered before parsing was completed?
body: <p>Im not sure why this is throwing the error End of stream encountered before parsing was completed. I looked at this <a href="https://stackoverflow.com/questions/306596/end-of-stream-encountered-before-parsing-was-completed">link</a> but nothing on there fixed the problem in my case.  I used break points to find the exact point it throws the error witch is </p>
  
  <pre><code>       Console.WriteLine("Message from client ");
  </code></pre>
  
  <p>Thanks in advance </p>
  
  <pre><code>   if (stream.DataAvailable)
     {
         byte[] buffer = new byte[10024];
         int byteCount = stream.Read(buffer, 0, buffer.Length);
         byte[] inBytes = new byte[byteCount];
         for (int counter = 0; counter &lt; byteCount; counter++)
             inBytes[counter] = buffer[counter];
         BinaryFormatter formatter = new BinaryFormatter();
         MemoryStream memory = new MemoryStream();
         memory.Write(inBytes,0,inBytes.Length);
         object message = (object)formatter.Deserialize(memory);
         Console.WriteLine("Message from client ");
         memory.Close();
     }
  </code></pre>
  
  <p>Edit* this was my bad nothing was wrong with the actual code here i made the mistake on the client end. i used Encoding.ASCII Instead of a binaryformatter.</p>