/// <summary> /// Determines if a client is still connected to an endpoint /// </summary> /// <param name="client"></param> /// <param name="poll">uses poll if set to true, can be more accurate but decreases performance</param> /// <returns>determines whether the client is still connected</returns> public static bool IsConnected(this EasyTcpClient client, bool poll = false) { if (client?.BaseSocket == null) { return(false); } if (!client.BaseSocket.Connected || !poll && client.BaseSocket.Poll(0, SelectMode.SelectRead) && client.BaseSocket.Available.Equals(0)) { client.HandleDisconnect(); return(false); } return(true); }