title: How to get all data in a TCP message with an end of message character?
body: <p>I have a TCP client / server application and had it working very well on the local machine.  However, the minute I used a client on a different machine, only small messages were delivered ( up to 20-30 bytes).  The minute the client needed to read larger data if would lock up.  What I believe the issue is is that the client is not receiving all of the data being send in one tcp packet. So in other words I had a single call to tcpClient.Client.Receive(tcpBuffer) and assumed that the tcpBuffer had all the data which it did on the local machines.  Now the messages that are being send by the server are all terminated in a byte which is unique in a message (0xFD).  I am not sure how to deal with this.  So one question is, is the NetworkStream.DataAvailable giving you the data that is available on the client or on the server?  Do I have to keep reading and looping until I get the 0xFD value?  How would one go about doing this efficiently?
  So basically I would like to replace the tcpClient.Client.Receive(tcpBuffer) with something like the following:</p>
  
  <pre><code>private static byte[] GetTcpResponse()
  {
      int arrayLength = tcpClient.Client.Receive(tcpBuffer);
      if (tcpBuffer[arrayLength - 1] == 0xFD)
      {
         return tcpBuffer;
      }
      else
      {
          //this is where I am hung up
      }
  }
  </code></pre>
  
  <p>So where I am hung up can be seem from the above. Do I just do another Receive?  What if there is no data yet? 
  Thanks, Tom</p>