소스 검색

Socket SendAsync SocketAsyncEventArgs的BytesTransferred==0也表示对方连接已断开

tanghai 7 년 전
부모
커밋
4602b7fcc2
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs

+ 7 - 0
Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs

@@ -305,6 +305,13 @@ namespace ETModel
 				this.OnError((int)e.SocketError);
 				this.OnError((int)e.SocketError);
 				return;
 				return;
 			}
 			}
+			
+			if (e.BytesTransferred == 0)
+			{
+				this.OnError(ErrorCode.ERR_PeerDisconnect);
+				return;
+			}
+			
 			this.sendBuffer.FirstIndex += e.BytesTransferred;
 			this.sendBuffer.FirstIndex += e.BytesTransferred;
 			if (this.sendBuffer.FirstIndex == this.sendBuffer.ChunkSize)
 			if (this.sendBuffer.FirstIndex == this.sendBuffer.ChunkSize)
 			{
 			{