Checking network availability
I'm currently writing a very small app designed to perform auto-authetication to a wifi network. The case is a bit weird :
- the OS network layer first connects to the wifi network (unencrypted)
- the user log into the network through a browser
- the network connection is closed by the server every hour or so
My goal is to get rid of step 2 and 3. I already achieved half of it. Authentication is as simple as a properly formatted post reqest to a static IP. The second part however is giving me headaches... I tried several methods to determine whether the connection was working or not (including but not limited to QTcpSocket::connectToHost(), QHostInfo::fromName() and QHttp::get()) and none worked properly... It looks like there is some caching somewhere inside Qt which renders these approaches plain useless (or I may also be doing something wrong...).
Any hints on how to achieve this in a pure Qt way?
Re: Checking network availability
Do you mean that connectToHost still works if there's no signal, therefore no connection?
If that is the case, I would like to buy your computer... Internet with to ISP's. That's SF :).
Really, there are some platform dependent solutions... I can give you some hints on Windows, but I assume you need something for Linux.
Re: Checking network availability
Quote:
Originally Posted by
marcel
Do you mean that connectToHost still works if there's no signal, therefore no connection?
If that is the case, I would like to buy your computer... Internet with to ISP's. That's SF :).
No SF... The network connection is still active but the wifi router does not treat request properly, it forwards the user to the login page when using a browser. The trouble is that if you are downloading things, or playing on the net you got screwed before you have a chance to fix things... My approach is to periodically check for working network connection by sending a get request to a fixed address (I know exactly what I'm supposed to get back) and determine by a simple comparision whether the network is fully working or needs re-authentication.