You want to be careful using this trick, as it may not always produce correct results when there is a captive portal, as well as in some other scenarios.
Something like this (Untested, should work) may produce better results:
public override void OnEnter()
{
try
{
//Dns.GetHostEntry("www.google.com");
var text = UnityEngine.WWW.GetURL("http://www.msftncsi.com/ncsi.txt");
if (text == "Microsoft NCSI")
Fsm.Event(internetIsOn);
else
Fsm.Event(internetIsOff);
}
catch
{
Fsm.Event(internetIsOff);
}
Finish();
}
Basically...
If you're online somewhere with a click-through agreement, the DNS returns the address of the router until someone opens a web browser, views the page, and clicks the button. So checking the DNS returns back "yep, I have an Internet connection" -- when, in fact, you don't yet. And if your program then tries to connect to the master server or whatever, it gets the IP address of the wifi router and not of the actual website you want to connect to.
That's how they get you to look at the click-through page, no matter what you type in the address bar. You know the page that says "you're entitled to my immortal soul if you continue to access via this hotspot."
Microsoft, Google, Apple and Ubuntu all ran into this -- and all solved it by simply hitting a web page. Apple ran into another variant of it (having to do with caching on some hotspots), and went to a randomized URL as a result (a traditional cache-buster in the URL)