How to check if TcpClient Connection is closed?

Posted by Superdumbell on Stack Overflow See other posts from Stack Overflow or by Superdumbell
Published on 2009-09-07T03:41:22Z Indexed on 2010/05/24 17:11 UTC
Read the original article Hit count: 392

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about socket