I never said the ping idea was a bad one, just not a broad one. Consider blocked icmp packets, custom or wrong tcp-ip settings, some routers, some firewalls or settings of firewalls, secure systems, limited access systems all of the above MAY result in "no connection found" however still May be able to resolve a domain (internet access). Again just not a broad solution.

Plus, Ping is slow to execute.