09-30-2011 07:27 AM
Hi all,
What's the best way these days to check for a working internet connection?
LV 2010.
Thanks,
Battler.
09-30-2011 07:49 AM
A simple way would be to open a TCP connection to a Webserver on port 80, then close it again. Check the error cluster.
09-30-2011 08:26 AM - edited 09-30-2011 08:28 AM
I have a VI which does exactly that however, it returns an error and yet I definately have an internet connection. So it doesn't work for some reason.
I believe the IP address is for NI.com server?
Another problem with this solution is the delay. There has to be a faster way. Getting this way to work at the very least would also be good.
09-30-2011 08:31 AM - edited 09-30-2011 08:32 AM
I don't know that IP address (I get a timeout as well), but you could just try www.ni.com or www.google.com. No need for an IP address, the protocol will look that up for you.
09-30-2011 08:35 AM
@battler. wrote:
I have a VI which does exactly that however, it returns an error and yet I definately have an internet connection. So it doesn't work for some reason.
I believe the IP address is for NI.com server?
While 130.164.140.26 may resolve back to ni.com, it is not what DNS registrations show as the IP address for ni.com. One valid one is 208.94.146.81. For now. You should really use names, not IP addresses.
Another problem with this solution is the delay. There has to be a faster way. Getting this way to work at the very least would also be good.
The delay of what? The delay only occurs if there's no connection established, in which case you hit your timeout.
09-30-2011 08:42 AM
I'll use names. Thanks,
I'm still not satisfied this is the best solution. If there isn't a connection my application should do something else, but it needs to wait for timeout which introduces delay. What's an appropriate timeout for all situations?
Can I do something with System Exec instead such as check ping?
09-30-2011 08:50 AM
You can use ping, but you'll have to give it some timeout as well. So I don't think that changes anything.
What is a good timeout... If you look at typical ping response times they might be in the ms range, so with 100ms timeout you should in most cases be fine. But there might be false timeouts in some cases when the network is busy.
09-30-2011 08:52 AM
Is there Windows registry entry?
09-30-2011 08:54 AM
@battler. wrote:
Is there Windows registry entry?
For what?
09-30-2011 08:57 AM
@dan_u wrote:
You can use ping, but you'll have to give it some timeout as well. So I don't think that changes anything.
What is a good timeout... If you look at typical ping response times they might be in the ms range, so with 100ms timeout you should in most cases be fine. But there might be false timeouts in some cases when the network is busy.
Ping isn't guaranteed to work, since a lot of sites close off ping as a protection against bots that try to check for live computers. Also, the operation of ping is dependent on the operating system.