Is it the right way to detect TcpClient connection closed state, or do I have to write zero bytes? I know it may return true if the sockets is not closed gracefully at the other side. What I need is to detect closed sockets by Operating System.
static bool IsConnected(TcpClient tcpClient)
{
if (tcpClient.Client.Poll(10, SelectMode.SelectError))
return false;
if (!tcpClient.Client.Poll(10, SelectMode.SelectWrite))
return false;
return true;
}