当我用Windows Ping一个远程系统时,它会显示没有回复,但是当我使用C#进行ping时,它会显示成功。Windows是正确的,设备未连接。为什么我的代码能够在Windows无法ping通时成功ping通?
这是我的代码:
Ping p1 = new Ping();
PingReply PR = p1.Send("192.168.2.18");
// check when the ping is not success
while (!PR.Status.ToString().Equals("Success"))
{
Console.WriteLine(PR.Status.ToString());
PR = p1.Send("192.168.2.18");
}
// check after the ping is n success
while (PR.Status.ToString().Equals("Success"))
{
Console.WriteLine(PR.Status.ToString());
PR = p1.Send("192.168.2.18");
}
PR.Address
、PR.RoundtripTime
、PR.reply.Buffer.Length
和PR.Options.Ttl
)?同时,请确保你的代码中使用的是正确的IP地址,而不是测试IP地址。 - Jon Senchyna