System.Net.Sockets.SocketExtensions.IsConnected C# (CSharp) Method

IsConnected() public static method

Determines if the connection to the machine on the other side of the socket is still active. Serves the same purpose as TcpClient.Connected and TcpListener.Connected.
public static IsConnected ( this iSocket ) : bool
iSocket this
return bool
        public static bool IsConnected(this Socket iSocket)
        {
            try
            {
                return !(iSocket.Poll(1, SelectMode.SelectRead) && iSocket.Available == 0);
            }
            catch
            {
                return false;
            }
        }
SocketExtensions