c# 实时监控服务器网络连接
实时监控网络连接的大概思路,以及具体方法 --------------------编程问答-------------------- InternetGetConnectedState API。详细见http://msdn.microsoft.com/en-us/library/windows/desktop/aa384702%28v=vs.85%29.aspx --------------------编程问答-------------------- 看不太懂啊 ,英语不好 --------------------编程问答--------------------
那就去学好,或者别干这个了。 --------------------编程问答-------------------- C#里面有Ping类,可以开个线程定时的去ping 服务器,看看是否能通
class PingSwitch--------------------编程问答--------------------
{
public static bool DoPing(string ip)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "a";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(ip, timeout, buffer, options);
return reply.Status == IPStatus.Success;
}
}
C#里面有Ping类,可以开个线程定时的去ping 服务器,看看是否能通
class PingSwitch
{
public static bool DoPing(string ip)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "a";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(ip, timeout, buffer, options);
return reply.Status == IPStatus.Success;
}
}
补充:.NET技术 , C#