I need to check if the connection with the internet is working on an application. It will run in a touch-screen monitor, connected to a computer with Windows, so it will be a PC app.
I need a function that returns a boolean or anything like that, if the connection is ok or not.
I tried to use the Ping function, and it worked somehow, but even when the connection is lost, ir returns data in the ping.time, so not working so far, or I have not figured out how.
I’d like to know if anyone has already done something like that.
if (Application.internetReachability == NetworkReachability.NotReachable)
Debug.Log(“Error. Check internet connection!”);
To truly know you’re online, you need to implement “captive portal detection”, to know if you’re e.g. hitting a public WiFi login page. So just checking Application.internetReachability or doing a Ping to some address doesn’t guarantee you can successfully make connections or make WWW requests.
I have made an easy asset called Internet Reachability Verifier. It keeps you up-to-date whether you have verified internet access (WWW requests can be done).
More info here: Internet Reachability Verifier by Strobotnik (for Unity®)