How to check if TcpClient Connection is closed?
问题 I'm playing around with the TcpClient and I'm trying to figure out how to make the Connected property say false when a connection is dropped. I tried doing NetworkStream ns = client.GetStream(); ns.Write(new byte[1], 0, 0); But it still will not show me if the TcpClient is disconnected. How would you go about this using a TcpClient? 回答1: I wouldn't recommend you to try write just for testing the socket. And don't relay on .NET's Connected property either. If you want to know if the remote end