瀏覽代碼

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)
 			{
 			{