My app (Lightwright) needs to know whether or not the user has internet access. I've been doing it using a Shell to ping Google. In this code, "Me" is a subclass of Shell:
Dim Astr as String = "ping -c 2 google.com"
In the .DataAvailable event, I check the .Result property to see if it contains "google", which it would if it was able to connect to Google
If .Result contains "cannot resolve" or "could not find host" or "unknown host", then I know it failed. This works great for 99% of my users, but recently there have been a few where it fails.
Today I had a really good bug report on this from, which said:
"I have an internet connection (en8, wired, through a USB-C dock, is primary in service order, then WiFi, en0). Both are working correctly, but Lightwright says it doesn't have an internet connection. I tried turning WiFi off to limit to just one wired connection, same error persists. For reference, I've attached my ifconfig report. Is it possible that Lightwright isn't fully enumerating all connections and checking for status active?"
I have no idea what an ifconfig report is, but here's a snippet:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
XHC1: flags=0<> mtu 0
XHC0: flags=0<> mtu 0
VHC128: flags=0<> mtu 0
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 fe80::aede:48ff:fe00:1122%en5 prefixlen 64 scopeid 0x8
media: autoselect (100baseTX <full-duplex>)
ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 fe80::102c:8b4c:5ea6:808f%en0 prefixlen 64 secured scopeid 0xa
inet 10.120.20.63 netmask 0xfffffc00 broadcast 10.120.23.255
Does anyone have a clue why ping doesn't work for this user? is there a better way to test for a connection? I could just try to download something from a known location (as if web pages never move), would that be more reliable?