public static class IPHelper
{
public static bool ConnectIP(string IPstr)
{
bool isFlag = false;
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "test";
byte[] buffer = Encoding.ASCII.GetBytes(data);
if (reply.Status == IPStatus.Success)
{
isFlag = true;
}
return isFlag;
}
}
{
public static bool ConnectIP(string IPstr)
{
bool isFlag = false;
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "test";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(IPstr,timeout,buffer,options);if (reply.Status == IPStatus.Success)
{
isFlag = true;
}
return isFlag;
}
}