Originally posted by Mick_2002
There is a ton of code out there that uses ping to test connectivity before connection, it's even more useful with COM...Older OS/2 ip stacks were fairly unstable so ping was the option of choice before the socket connection.
This is a bit beyond what Jennings wanted, but what about
cases where one is not using TCP/IP? Also, some firewalls
may block ping. It would be nice if there was a function
that did not need ping.
Originally posted by kochhar
This is a bit beyond what Jennings wanted, but what about
cases where one is not using TCP/IP? Also, some firewalls
may block ping. It would be nice if there was a function
that did not need ping.
Yes there is that chance that they are filter. But in this case, he has stated, I have a program that downloads updates and I'm guessing from his site. So he has control over what he allows in.
RawSock and SNMP are beyond the scope of this I'll probably reply further later....
I've finally gotten around to testing out the ping code.
A few more questions if I may ...
My work blocks incoming traffic that doesn't come through via the proxy server. Therefore, all pings external to our network will fail.
However, gethostbyname("slideshowdesktop.com") does return the resolved ip address for my website.
My thinking is that if i can resolve an internet hostname, then there must be an internet connection right ?
If the ping then times out, i can assume the presence of a firewall?
I'm wondering if simply using gethostbyname() on it's own is all i need to detect the presence of an internet connection ?
Thanks
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
I've finally gotten around to testing out the ping code.
A few more questions if I may ...
My work blocks incoming traffic that doesn't come through via the proxy server. Therefore, all pings external to our network will fail.
However, gethostbyname("slideshowdesktop.com") does return the resolved ip address for my website.
My thinking is that if i can resolve an internet hostname, then there must be an internet connection right ?
If the ping then times out, i can assume the presence of a firewall?
I'm wondering if simply using gethostbyname() on it's own is all i need to detect the presence of an internet connection ?
Thanks
DNS does not resolve connectivity (other than to the DNS server), just resolves the IP address listed in the DNS's db.
They don't have to have a DNS server, they can use a local host file, which is the same issue as above, but your not connecting to a DNS server, therefore your still clueless on whether you have connnectivity.
BTW: I can ping/tracert slideshowdesktop.com/www.slideshowdesktop.com so is the statement your making correct?
1. If i ping slideshowdesktop.com from cmd prompt, it comes back with "Pinging slideshowdesktop.com [216.167.114.177] ..."
The requests then either time out, or it returns "Reply from [proxy server adddress] : ndestination host unreachable.
Same happens if i try it with microsoft.com
So, I'm assuming the recvfrom timesout due to the firewall / proxy
However, and this is the important part to me, the very fact that slideshowdesktop.com resolves back to an ip address must surely indicate that there is a connection to an external network (i.e. the internet)? To resolve the ip address, it must have communicated with one of the 13 major route DN servers ?I doubt very much if anybody will put slideshowdesktop.com in their hosts file
Any thoughts?
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Originally posted by jase jennings
Thanks for the reply Mick
1. If i ping slideshowdesktop.com from cmd prompt, it comes back with "Pinging slideshowdesktop.com [216.167.114.177] ..."
The requests then either time out, or it returns "Reply from [proxy server adddress] : ndestination host unreachable.
Same happens if i try it with microsoft.com
So, I'm assuming the recvfrom timesout due to the firewall / proxy
However, and this is the important part to me, the very fact that slideshowdesktop.com resolves back to an ip address must surely indicate that there is a connection to an external network (i.e. the internet)? To resolve the ip address, it must have communicated with one of the 13 major route DN servers ?I doubt very much if anybody will put slideshowdesktop.com in their hosts file
Any thoughts?
Well, it does not mean _it_ communciated with one of the Major DNS servers, it means also it could communicate with it's own nameserver (it depends on the configuration), which is set to point to another name server in the hierarchy and replicate databases.
Just because you can resolve an address, does not mean the address is up, and as you can fail to resolve an address, does not mean that address is down. It's just a name to public block IP address lookup, it's not a connectivity check.
Suppose you failed to resolve the address. Again this doesn't mean your site is down, it means that you for whatever reason didn't get an authoriative answer from your DNS server for your address. And as long as router configuration and tables are up to par, I can still use your IP addr to connect.
You could probably go with the ping request timeout since you can tweak the timer on waiting for a reply in the call.
Either way, you should have a waitcursor/message saying your checking for updates....or do it in the background and if you find updates, then either update your code on the next run, or prompt the user if they want to update with the new code. Or check when your program exits. Lots of ways not to interfere with the user.
Originally posted by Mick_2002
Well, it does not mean _it_ communciated with one of the Major DNS servers, it means also it could communicate with it's own nameserver (it depends on the configuration), which is set to point to another name server in the hierarchy and replicate databases.
Why would my company list slideshowdesktop.com in their nameserver ? I can't figure out how gethostbyname() can return an ip address to my website without communicating with a server outside of my companies internal network ...
Just because you can resolve an address, does not mean the address is up, and as you can fail to resolve an address, does not mean that address is down. It's just a name to public block IP address lookup, it's not a connectivity check.
Agreed. However, I'm not interested whether the address is up. I just want to know if a computer external to my network can be reached, thus indicating the internet.
Suppose you failed to resolve the address. Again this doesn't mean your site is down, it means that you for whatever reason didn't get an authoriative answer from your DNS server for your address. And as long as router configuration and tables are up to par, I can still use your IP addr to connect.
If I cannot resolve the address, then my using InternetOpenURL() on slideshowdesktop.com is going to fail. So not being able to resolve an address is as good as "site down" according to my updater. I do not wish to code in a static ip address for my update server, in case the provider changes it (or even i change provider) - if the ip changed in the future, this would 'break' my updater for older versions of the software.
You could probably go with the ping request timeout since you can tweak the timer on waiting for a reply in the call.
The problem is, my company does not allow icmp echo requests inbound, so the ping packets are never received. However, I am connected to the Internet ! Ping fails, but gethostbyname() succeeds.
Either way, you should have a waitcursor/message saying your checking for updates....or do it in the background and if you find updates, then either update your code on the next run, or prompt the user if they want to update with the new code. Or check when your program exits. Lots of ways not to interfere with the user.
I've had an Instant Updater in my software for 18 months now, but it doesn't work on a LAN with a firewall, and incorrectly determines the availability of the Internet when using a cable modem/router - it works perfect with dialup connections (even DSL) and across ICS. I'm now looking to address the issues
My updater is highly configurable.
1. will run silently in the background (when the internet is available), and popup a tray balloon (2k/xp), or a dialog (9x/me/nt4).
2. can be configured to run every x days, every time the app is run, or never
3. automatically runs every time when the software trial period has expired.
4. you can specify how you connect to the Internet, to give me a little help in determining the connection.
5. my updater will handle (and accelerate) the download from my website, then install itself (at users request)
Actually I've put a lot of design and coding effort into the updater, but I'm still plagued by some configurations saying "connected - look for an update", when the Internet is not available. It doesn't work across proxies either, which is my next big job
None of the above answers are meant as argumentative or are in disagreement - i'm merely trying to debate the issues with somebody who clearly knows what they're talking about (i.e. you
Thanks
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Ahh well that clears it up, I think there was a bit of confusion, as I thought we were talking, how can I reduce the 5 second timeout from a Connect(), which started like in the first or second response here.
What I want to explain in a round about way, is if your company has a NameServer. Your website name/Ip would most likely be cached, since it would be the authorative server for your domain, so there would be no need to fetch it from another domain name server, but that would be internal to your network and isn't worth discussing futher. But having said that, let us say you do have a nameserver at your site (or you can use this same scenario for a nameserver that your ISP provides within their domain namespace), your name server would then also know how to contact the authorative nameserver for a domain, say like www.microsoft.com. When you fetch that address it would ask the server that manages that domain. So yes you can determine that you are connected to the internet (or have been at some point and the NS db tables haven't kicked off a failed interval db update due to internet downage, I think I use to set my nameservers to 8 hours or 24 hours), provided it's not cached and the endpoint router to the provider isn't down (being picky) At least that's the way I remember it working, but I haven't played with DNS configuration/setup since working for a very small company many a year ago
I'll let this info churn around inside my tiny brain for a bit, and if it fails to compute, I may get back to you
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Originally posted by jase jennings
Thanks for the info.
I'll let this info churn around inside my tiny brain for a bit, and if it fails to compute, I may get back to you
Just remember whenever I say your network/your name server, I mean in the sense of your being the customer trying to connect to www.slideshowdesktop.com of course
You can use HTTP to retrieve your update file or simply use CONNECT to solve proxy issue. I am not sure why you want to check internet connection, why not just send a request to your update server to check if update process works or not.
> I am not sure why you want to check internet connection, why > not just send a request to your update server to check if
> update process works or not.
Two reasons.
If i check using wininet functions, and the user is not connected, its launches a dialup. If i want to check in the background, i need first know if the user is connected.
If i call code which needs to timeout, the application causes slow down on the users pc - it won't hang my app because i do it in a non-ui thread. All the same, it will cause slow down.
How would you do it?
I want to check my update server and download a file using http. I need to do it invisibly. If the user is not connected, and they ahve asked to be prompted, then my updater will ask them to connect.
What's your solution?
Thanks for you help
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
jase jennings,
I've attached a zip file containing an small application that
detects a internet connection by looking for the default gateway.
It has worked for me. If it works in the way that you need,
I'll post the source code.
The attached file name is "ReadMib.exe".
I've tried using the non-blocking WSAAsyncGetHostByName()
I guess if you don't have the hostname/IP stored in the
HOST file, it should work to determine a internet connection
It worked for me on Win98 -
I don't have a LAN, routers, electric gas music from Jupiter, etc.
to try it on.
I'm curious if it works for others.
Thanks for posting the code. However, it's not really a suitable approach.
1. "Not Connected" takes too long to time out
2. An asynchronous check is unsuitable, because the program needs to wait while it looks for a conection (it will still pump messages , but that's all)
3. If i run the test dlg while connected and then click the button, it will say connected. If i now close the inet connection and press the button again, it will still say i am connected. In fact, it willl continue always to say i am connected until i close the test dlg and run it again. Only then will it tell me "not conected", and it can take 20 seconds to respond.
I need a solution which works in a few seconds max, and will report correctly connected/not connected, even when the state of the connection changes during the lifetime of the running app.
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.