Asp.net实现的ping功能,可在虚拟主机执行
public
bool
Ping(
string
ip)
{
System.Net.NetworkInformation.Ping p =
new
System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingOptions options =
new
System.Net.NetworkInformation.PingOptions();
options.DontFragment =
true
;
string
data =
"Test Data!"
;
byte
[] buffer = Encoding.ASCII.GetBytes(data);
int
timeout = 1000;
// Timeout 时间,单位:毫秒
System.Net.NetworkInformation.PingReply reply =
p.Send(ip, timeout, buffer, options);
if
(reply.Status ==
System.Net.NetworkInformation.IPStatus.Success)
return
true
;
else
return
false
;
}
转载优特建站:http://www.youtiy.com/Articles/Item.aspx?Id=257
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。