Browse Source

调整粘包处理

develop
H Vs 8 months ago
parent
commit
45e13cef87
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      NearCardAttendance.Service/TcpServer/Handler/ProtocolHandler.cs

+ 2
- 2
NearCardAttendance.Service/TcpServer/Handler/ProtocolHandler.cs View File

@@ -110,7 +110,7 @@ namespace NearCardAttendance.Service.TcpServer.Handler
// Console.WriteLine(message);
}
// 过长且不完整
if (inputString.Length > messageLength)
if (inputString.Length > messagesStringLength)
{
var overLongbuffer = Unpooled.Buffer();
overLongbuffer.WriteBytes(Unpooled.WrappedBuffer(Encoding.ASCII.GetBytes(inputString.Substring(messageLength, inputString.Length- messageLength))));
@@ -118,7 +118,7 @@ namespace NearCardAttendance.Service.TcpServer.Handler
buffer = overLongbuffer;
}
// 数据完整
if (inputString.Length ==messageLength)
if (inputString.Length == messagesStringLength)
{
ReleaseBuffer();
}


Loading…
Cancel
Save