Testing if connected to the net

  • Thread starter Thread starter HardySpicer
  • Start date Start date
H

HardySpicer

Is there a vb.net library function that returns a true or false if you
are connected to the Internet.


Hardy
 
Is there a vb.net library function that returns a true or false if you
are connected to the Internet.


Hardy

The simplest way is to ping a known external server or address. You can do
that with System.Net.NetworkInformation.Ping class... Or, as much as I
dislike it - there is the My.Computer.Network.Ping thingy as well (or
something to that effect). I only mention it because if I don't, someone else
will :)
 
Be aware what you ask connected to the Net, there are enough proxies which
give you back IE pages while you are in fact disconnected from Internet.

Cor
 
I once needed a quick and dirty way to do this so I found this code online
and it did the trick.

If My.Computer.Network.Ping("www.google.com", 1000) Then
MsgBox("Server pinged successfully.")
Else
MsgBox("Ping request timed out.")
End If

I figured if I can ping google, I am online...if not, I am not.

Did the trick with a minimal amount of coding lines for me.

Miro
 
Cor brings up a verry good point

Wich i encounterd a lot in the past with my projects , only then exactly the
oposit as you might expect :-)
My programs only needed a Http connection ( web services , and update
facilities ) , however if a computer is located in a managed lan
i has often a managed gateway ( proxy server , connectbox , fortygate etc
etc ) so a ping beyond the lan, does not work however Http on port 80 or
8080 is no problem at all , so i made all my programs proxy capable and
included a configuration screen for the event that other ports as the usual
are used for http trafic


So the question to you is do you want Http trafic or doe you want to
comunicate on other ports , this will give you a lot more pitfalls to deal
with ( software firewalls , gateway firewalls , paranoid providers etc
etc )


regards

Michel
 

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

Similar Threads

Funny Error 2
How do I mute the microphone? 2
Maximising the web page 4
Reading a text file and reading 14
Nelson at Trafalgar 2012 4
Sound Card 2
Serial Ports 3
Popup Menu 4

Back
Top