Reputation: 2809
What is the default time of ping? I use the code below to send ping to tcp devices. When does IPStatus fall to timeout?
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);
}
}
Thank you.
Upvotes: 13
Views: 21161
Reputation: 1062770
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.
And if we check in reflector, indeed we see:
public PingReply Send(string hostNameOrAddress)
{
return this.Send(hostNameOrAddress, 5000, this.DefaultSendBuffer, null);
}
Upvotes: 25