AutoDetection of Internet Connection

  • Thread starter Thread starter Rohan Ranade
  • Start date Start date
R

Rohan Ranade

Hi. I am facing a difficulty. My program should fire up
automatically, everytime the user connects to the
Internet. How can it be done using C#? Is there any API
call?

Thank You.
 
Hi Rohan,

I don;t know if there is a API call that let you know when a DialUP
connection is established, even so that do not assure that that connection
is connected to the "internet" it may be a direct connection between two
machines to play a game for example.

Other thing you can do is use a timer and test the connection to a given
address. this is what the ICQ/MSN, etc do.

Hope this help,
 
One thing you can do it to get a list of IP addresses on the machine and
check if you have valid IP Address (one belongs to Class A or B or C and
not your local host IP (127.0.0.1).
you can use System.NET.Dns and System.NET.IPHostEntry to get this info:
eg:
System.Net.IPHostEntry h =
System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName());
foreach (System.Net.IPAddress ip in h.AddressList)
CheckIP(ip);// do the check here

thanks,
Mohamed
--------------------
 
Back
Top