An elegant / simple way to check whether internet is available or not.
- by Trainee4Life
I did a quick search on how to check whether Internet is available or not. Most of them talked about making InterOp calls to wininet.dll.
One of the answers pointed towards System.Net.NetworkInformation namespace. Exploring the namespace I found a class Ping which could be used to pinging to our servers from code, and checking whether server is available or not.
What I want to ask is how this solution compares to other solutions?
Ping soPing = new Ping();
var soPingReply = soPing.Send("www.stackoverflow.com");
if (soPingReply.Status != IPStatus.Success)
{
// SO not available
}