byte[] Receivebytes = new byte[0];
int ReceivebyteRead = 0; //单次接收的长度
int BytesMergeIndex = 0; //要合并bytes的位置
NetworkStream NS = tcpclient.GetStream();
if(NS.CanRead)
{
do
{
byte[] TempBytes = new byte[tcpClient.ReceiveBufferSize];
ReceivebyteRead = NS.Read(TempBytes, 0, tcpClient.ReceiveBufferSize);
Array.Resize<byte>(ref Receivebytes,
Receivebytes.Length + ReceivebyteRead);
Array.ConstrainedCopy(TempBytes, 0, Receivebytes,
BytesMergeIndex, ReceivebyteRead);
BytesMergeIndex += ReceivebyteRead;
Thread.Sleep(200);
}while(NS.DataAvailable)
BinaryFormatter BF = new BinaryFormatter();
MemoryStream MS = new MemoryStream(Receivebytes);
Data_List = (List<object>)BF.Deserialize(MS);
}