A simple utility to check if a host is reachable on the network.
Trying to discover if a host is available on the local network can be tricky if you want to use the ping
utility that is shipped with windows. If you try to ping a host on the local network, the exit code will always be 0 (Success), regardless of the hosts existance. Parsing the output can become a real hassle if you have to support multiple languages since the output depends on the locale settings.
This small utility will tell you via exit code if a host is really reachable or not.
$ MiniPing.exe
MiniPing - A minimal ping program
ExitCodes:
0: Host is reachable
1: Host is not reachable
2: An exception occured
To ping a host, add the hostname or IP Address:
$ MiniPing.exe 127.0.0.1
Received Response in 0 ms
This work is more or less inspired by two code snippets I found on the internet:
- ICMP-Echo-API ("Ping") Wrapper-Unit v1.04 (german)
- How to ping an IP address in Delphi 10.1 without using Indy components?
I didn't use them, because their use case was much too heavy for the application or the used api is deprecated.
Maybe: Adding a customizable timeout
If you want to contribute, please don't hesitate to open a pull request. If you have any questions, please ask them in a issue.
This project is licensed under the MIT License.