C# Socket 接受数据不全的处理
2021-07-01 10:08
阅读:636
//通过clientSocket接收数据
int receiveLength = 0;
int index = 0;
while (clientSocket.Available > 0)
{ //参数 数据缓存区 起始位置 数据长度 值的按位组合
receiveLength += clientSocket.Receive(result, index, clientSocket.ReceiveBufferSize, SocketFlags.None);
index += receiveLength;
}
return Encoding.GetEncoding("GB18030").GetString(result, 0, index);
评论
亲,登录后才可以留言!