Click here to Skip to main content
15,921,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

how to check internet connection is available or not ?

i want to like CHECK internet connection is lost.
that time my windows base application popup windows "Your internet connetion is lost. "

AND my system in domain. "xyz.local"

thank you ,
Updated 7-Feb-14 2:39am

To do this I have a HelloWorld HttpHandler registered on a WebServer.

This is a simple handler with a simple HelloWorld response.

I use the WebRequest object to call this handler. If I get the HelloWorld response then I'm online.
Share this answer
using System.Net.Sockets;

public Form1()

//Calling method to test if connected .

private bool Method() //Third way, slightly slower than Method 1

//Tes for internet connection.
TcpClient tcpClient = new TcpClient("", 80);
//Provides client connections for TCP network services

//close if conneted.

//write what ever to want it to do here

//show value of connected or disconnected.
pbConnection.Value = 80;
lblLable.Text = "Connected ";

return true;
catch (System.Exception ex)
//if not connected
lblLable.Text = "Disconnected";
return false; //Not connected
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900