0

I code simple web browser and i want to show message when the connection is not available.I used "try catch" but it not work.How I detect my network connection is available or not.

1 Answers1

0

Ping a DNS that is almost up Like 4.2.2.4,4.2.2.3,4.2.2.2

Ping myPing = new Ping();
String host = "4.2.2.4;
byte[] buffer = new byte[32];
int timeout = 1000;
PingOptions pingOptions = new PingOptions();
PingReply reply = myPing.Send(host, timeout, buffer, pingOptions);
if (reply.Status == IPStatus.Success {
  // presumably online
}
KF2
  • 9,887
  • 8
  • 44
  • 77