I'm looking for a way to check if a server is still available. We have a offline application that saves data on the server, but if the serverconnection drops (it happens occasionally), we have to save the data to a local database instead of the online database. So we need a continues check to see if the server is still available.We are using C# for this application..Pls give the code for this..
Loading
Praveen Raveendran PillaiPosted May 12, 2014, 1:27 AM
I am getting the response for http://traffic.telecom.co.in as false.
I hope its correct. May I know what is the exact issue?
Rini ShironPosted May 9, 2014, 8:19 AM
Thank you for your responds..i am using the same code..but when the server is down this check the code..and says the server is available
my code is
public static bool IsConnectedToInternet
{
get
{
Uri url = new Uri("http://traffic.telecom.co.in");
string pingurl = string.Format("{0}", url.Host);
string host = pingurl;
bool result = false;
Ping p = new Ping();
try
{
PingReply reply = p.Send(host, 3000);
if (reply.Status == IPStatus.Success)
return true;
}
catch { }
return result;
}
}
Praveen Raveendran PillaiPosted May 9, 2014, 8:11 AM
Pass the server url to this method.