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.
Asked
Active
Viewed 1,352 times
0
-
but it not work means? please be more specific – Karthik Jul 05 '13 at 15:38
1 Answers
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