Can anyone advise what the best way to check (using .NET 3.5) if a remote server is available?
I was thinking of using the following code but would like to know if a better way exists if the community has another option.
TcpClient client = new TcpClient("MyServer", 80);
if (!client.Connected)
{
throw new Exception("Unable to connect to MyServer on Port 80");
}
client.Close();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…