I had a scenario which need to test whether server available or not for my application.So i wrote following code to accomplish that.
.net framework has set of classes which support to Ping to the specified host.
public bool IsAvailableHost(string hostName)
var ping = new Ping();
PingReply reply = ping.Send(hostName);
return reply != null && reply.Status == IPStatus.Success;
catch (Exception ex)