发生了数据损坏的现象
bobowire opened this issue · 3 comments
bobowire commented
'
for (int i = 0; i < 30; i++)
{
clientSt.kcp.Send(Encoding.UTF8.GetBytes($"第{i}次数据_{DateTime.Now}"));
}
'
在第9次,第17次时,大概率出现数据损坏,“据”位置乱码
以下是数据接收代码:
'
client.kcp.Update(DateTime.UtcNow);
int readLength = client.kcp.PeekSize();
while (readLength > 0)
{
var bytes = new byte[readLength];
int length = client.kcp.Recv(bytes);
if (length > 0)
{
//todo:已经接收到完整包
Console.WriteLine(Encoding.UTF8.GetString(bytes.Take(length).ToArray()));
}
readLength = client.kcp.PeekSize();
}
'
bobowire commented
有QQ群的话,可以提供以下,我传个Demo文件
KumoKyaku commented
可以发送到我的邮箱