Best way to check if host is up

Hi there,

I would like your opinion about the best way to know if a host is up or down, I tried using ping , it works, but I got a delay around 4s on loop.

any suggetion to do it faster?.

thanks you.

Welcome to the forum

Please read the How to get the best out of this forum

Here are a few points that could help answer your question:

  • Is the host in the same room or on the other side of the world?
  • What does the network between the two devices look like? (WiFi, Ethernet, router, ISP ...)
  • What board do you have?
  • Which library are you using?
  • Did you try to ping the host from a different machine?
  • What was the shortest and longest delay from different machines?
  • Can you post a small example code that demonstrates your issue?

I'm using ESP32 and Host is in same network ( LAN ) , it isn't a issue, it's just that ping ( ESP8266Ping.h ) takes too much time to return result and I would like to know if there is any other solution to improve it ( telnet? ) other way to know if host is up

if(Ping.ping(getIP())){
     dotrue();
}else{
     dofalse();
}

I did a quick Google search and found the following library.

The ping function has a second parameter count which is set to 5 as default inside the library. When I called the function with count set to 1, I got an execution time of a few milliseconds over 1 second. (6 to 25ms) With the parameter set to 0, the function takes 10 seconds but sends many pings during that time.

Would ~1 second be good enough for you? Or would you like something faster? How fast would be good enough? If that can be changed there is likely a trade-off between execution time and failure rate.

If you provide a link to the library you are using (e.g., GitHub), I could have a look at the source code.

Thanks you Klaus_K, I set 1 after and delay was OK for my project.

if(Ping.ping(getIP(),1)){
     dotrue();
}else{
     dofalse();
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.