ping的默认时间是多少?我使用下面的代码向 tcp 设备发送 ping。 IPStatus 什么时候超时?
private static void ApplyPing(Topology.Runtime rt)
{
try
{
if (rt.TcpClient != null)
{
string ip = rt.Ip;
if (new Ping().Send(ip).Status != IPStatus.Success)
{
Service.WriteEventLog(string.Format("{0} ping error.", ip), EventLogEntryType.Warning);
rt.Disconnect();
}
}
}
catch (ArgumentNullException ex)
{
}
catch (Exception ex)
{
Service.WriteEventLog(ex, EventLogEntryType.Error);
}
}
谢谢。
最佳答案
The method waits five seconds for an ICMP echo reply message. If it does not receive a reply in that time, the method returns and the Status property is set to TimedOut.
如果我们检查反射器,我们确实会看到:
public PingReply Send(string hostNameOrAddress)
{
return this.Send(hostNameOrAddress, 5000, this.DefaultSendBuffer, null);
}
关于c# - 默认 ping 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17162703/