|
|
|
@ -338,7 +338,7 @@ namespace Module.Socket.Tool
|
|
|
|
|
{
|
|
|
|
|
readByte = ClientStream.Read(FixedBuffer, 0, BufferSize);
|
|
|
|
|
if (readByte == 0) break;
|
|
|
|
|
else if (readByte >= 24)
|
|
|
|
|
else if (readByte >= 9)
|
|
|
|
|
{
|
|
|
|
|
bytesResult = GetReadResult(FixedBuffer, readByte);
|
|
|
|
|
}
|
|
|
|
@ -387,7 +387,27 @@ namespace Module.Socket.Tool
|
|
|
|
|
Thread.Sleep(20);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool checksumDomainReceive(byte[] data)
|
|
|
|
|
{
|
|
|
|
|
bool bResult = false;
|
|
|
|
|
int checksum = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 8; i < data.Count() - 1; i++)//这里有校验域所以减一
|
|
|
|
|
{
|
|
|
|
|
checksum += data[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//foreach (byte b in data)
|
|
|
|
|
//{
|
|
|
|
|
// checksum += b;
|
|
|
|
|
//}
|
|
|
|
|
// 取校验和的低8位
|
|
|
|
|
byte b1 = (byte)(checksum & 0xFF);
|
|
|
|
|
byte b2 = data[data.Count() - 1];
|
|
|
|
|
if (data[data.Count() - 1] == (byte)(checksum & 0xFF))
|
|
|
|
|
bResult = true;
|
|
|
|
|
return bResult;
|
|
|
|
|
}
|
|
|
|
|
private List<byte[]> GetReadResult(byte[] bytes, int readLen)
|
|
|
|
|
{
|
|
|
|
|
List<byte[]> lstResult = new List<byte[]>();
|
|
|
|
@ -415,6 +435,9 @@ namespace Module.Socket.Tool
|
|
|
|
|
|
|
|
|
|
// 使用Array.Copy方法将原始数组中的一部分复制到新数组
|
|
|
|
|
Array.Copy(bytesCppy, i, newBytes, 0, leng);
|
|
|
|
|
|
|
|
|
|
//校验域是否正确
|
|
|
|
|
if (checksumDomainReceive(newBytes))
|
|
|
|
|
lstResult.Add(newBytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|