[fpc-pascal] How to check if a network is available?
Bo Berglund
bo.berglund at gmail.com
Sun Jun 20 09:36:31 CEST 2021
On Fri, 18 Jun 2021 08:34:43 -0400, James Richters via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
>Do a Ping to an address on the network to see if it's connected?
>
I would need a ping with only one execution so I can put it into a loop and
break after a successful ping or break after some timeout value.
Seems like the ping syntax differs between Linux and Windows for some strange
reason...
On Windows something like this then (10.117.3.1 being the IP address inside the
tunnel of the OVPN server itself):
When connected:
---------------
ping -n 1 -w 500 10.117.3.1
Pinging 10.117.3.1 with 32 bytes of data:
Reply from 10.117.3.1: bytes=32 time=2ms TTL=64
Ping statistics for 10.117.3.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
Before connection:
------------------
ping -n 1 -w 500 10.117.3.1
Pinging 10.117.3.1 with 32 bytes of data:
Request timed out.
Ping statistics for 10.117.3.1:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss)
So looking for % loss in the response would be a way.
0 means no connection yet 100 means we are connected.
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list