best way to determine internet connection when have only Lan ?

  • Thread starter Thread starter semedao
  • Start date Start date
S

semedao

Hi,
I have problem to determine that I don't have any internet connection when I
have Lan Nic available that is connected to other computer and not to the
internet.

I am using the NetworkInterface.GetIsNetworkAvailable Method and then the
NetworkInterface.GetAllNetworkInterfaces Method
but it is not good enough for this situation.
my question is if the only solution will be to make some ping / connect to
server that must run all the time , and in case of exception to understand
that I don't have internet connection , or , there is some other better
method to do it ?
Thanks
 
thanks , I already know , I asked if there other way witout to make some
call over sockets to determine this
 
You could just use the HttpWebRequest class and request a web page.
Something you know is always available, like www.hotmail.com, etc.
If you get a response, connection is good. If you get a bad error code,
then its bad.

I wrote my own connection monitor but it works a bit differently. It
connects to my home router and parses the web page. If it discovers
that the router page says it is "Disconnected" it sends a reboot
command. So for me, I never need to actually ping or connect to a site
outside of my lan.

Steven
 
Ok , but in the end , forprogram that we cannot know the end user
configuration
I must use some method of connection to external location , there is no
other way...
 
Ok , but in the end , forprogram that we cannot know the end user
configuration
I must use some method of connection to external location , there is no
other way...

If you think about it, how could it work any other way? The only way to
determine connectability, is to try to access some kind of destination and
check the response. Whether you do this with ping or HttpWebRequest or any
other method is moot.

In WinInet (Win32API) there is an InternetCheckConnection function you might
want to try to PInvoke. Check msdn.microsoft.com for more info
 
Peter's right. There's not magic box called "internet" that you can
just ask if you are active.
You need a remote host to attempt to connect to. Whether that is a host
you control or not is a moot point. There are some hosts that will
never disappear that you could always use.
For example, your ISP's name servers or perhaps the domain regulator
for your country. I only suggested Hotmail because its been around a
long time and is likely to be around for a long time still.

HttpWebRequest is good because it will be more like your standard
browser's connection.
Some server's block ping for security reasons (ICMP?) but still host
pages.

Good luck,
Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top