With regards to handling a TCP/IP connection using the TcpClient class, is there an alternative for checking whether the remote host has closed the connection other than waiting for the NetworkStream.Read method to return a 0?
With regards to handling a TCP/IP connection using the TcpClient class, is there an
Share
You can use
IOControlCode.KeepAliveValueson theTcpClient.Clientto guarantee that a keep-alive check is made at least on the specified interval and then check theTcpClient.Client.Connectedproperty.An example how to use it: