Tcp C# 数据过多造成数据丢失,求助
if (!isFailed){
try
{
byte[] buffer = new byte[1024 * 1024];
int totalLengh = 0;
do
{
int headLen = stream.Read(buffer, totalLengh, buffer.Length - totalLengh);
totalLengh += headLen;
if (totalLengh == buffer.Length)
{
string datagram = Encoding.UTF8.GetString(buffer, 0, totalLengh);
}
if (headLen == 0)
{
//finished
errorMessage = "远程服务器已关闭,无法接收数据";
isFailed = true;
break;
} // 读数据包体本身
数据大于1M,datagram没有完全接收数据,咋办?