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;
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