diff --git a/src/HiSocket/TcpConnection/Socket/TcpSocket.cs b/src/HiSocket/TcpConnection/Socket/TcpSocket.cs index 0c87845..84dda0b 100644 --- a/src/HiSocket/TcpConnection/Socket/TcpSocket.cs +++ b/src/HiSocket/TcpConnection/Socket/TcpSocket.cs @@ -211,7 +211,14 @@ private void EndSend(IAsyncResult ar) Array.Copy(SendBuffer.Array, SendBuffer.ReadPosition, sendBytes, 0, sendBytes.Length); SocketSendEvent(sendBytes); SendBuffer.MoveReadPosition(length); - Send(); + if (length > 0) + { + Send(); + } + else + { + DisconnectedEvnet(); + } } private void Receive() @@ -247,7 +254,14 @@ private void EndReceive(IAsyncResult ar) ReceiveBuffer.MoveWritePosition(length); var bytes = ReceiveBuffer.ReadAll(); SocketReceiveEvent(bytes); - Receive(); + if (length > 0) + { + Receive(); + } + else + { + DisconnectedEvnet(); + } } public void DisConnect()