检查服务器是否可用 [英] Check the server is available or not
本文介绍了检查服务器是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种检查服务器是否仍然可用的方法。我们有一个离线应用程序,可以在服务器上保存数据,但如果服务器连接断开(偶尔会发生),我们必须将数据保存到本地数据库而不是在线数据库。所以我们需要继续检查以确定服务器是否仍然可用。我们正在使用C#进行此应用程序..请为此代码提供代码。我的代码是
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..my code is
using System.Net.NetworkInformation;
Uri url = new Uri("http://traffic.ebentelecom.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;
但它没有工作
but its not working
推荐答案
以下链接会给你一个想法:
check-remote-server
希望有所帮助:)
The below link will give you an idea:
check-remote-server
Hope it helps :)
这篇关于检查服务器是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文