Page 1 of 1

Check Internet Connection

Posted: Tue Nov 29, 2005 4:35 pm
by Muskelkatermann
Hi,

I'm thinking about how to check whether a client machine is online or not.

I thought of download a specific File from a server and if the returned code is OK, then the machine must be online.

But I guess there is a better way!
How would you solve the Problem?



Greetings

Re: Check Internet Connection

Posted: Tue Nov 29, 2005 4:50 pm
by Ryan Norton
Muskelkatermann wrote: But I guess there is a better way!
How would you solve the Problem?



Greetings
Possibly

Code: Select all

wxDialUpManager::IsOnline

Posted: Tue Nov 29, 2005 11:02 pm
by emarti
Please, browse "wx\samples\dialup" sample.

Posted: Wed Nov 30, 2005 8:39 am
by Muskelkatermann
I think this work's only for dialup connections, not?

What about permanent connection with a DSL Router, or Proxy?

greetings

Posted: Wed Nov 30, 2005 11:35 pm
by emarti
Not only dialup connection. it works for DSL.

Posted: Mon Jan 09, 2006 11:25 am
by Muskelkatermann
Hi,

I just tested the wxDialUpManager::IsOnline but this isn't what i want...

It just checks whether all my eth() devices are connected, example:

Eth(0) Cable is unplugges
Eth(1) is removed (pcmcia)
Eth(2) (IEEE 1394) cable is unplugged

wxDialUpManager::IsOnline returns true until i deactivate even the Eth(2).

Any other ideas for an internet connection test ?

greetings

Posted: Mon Jan 09, 2006 12:33 pm
by Jorg
I think it is very hard. Even Firefox tries and tries to connect, even when my connection is down. So, what is the gain in doing so. When you're not able to connect to the other side, either the other PC is dead or your internet connection is.

- Jorgen

Posted: Mon Jan 09, 2006 1:01 pm
by Muskelkatermann
Ok,

currently i check for the connection by getting the input stream of a file which is located on the server.

In General that works fine, but today i had the following situation:

I wanted to download a file which is generated by a serversided script(ColdFusion) but something was wrong with the server, and it took up to two minutes until GetInputStream returned data...

I don't like it when the user just has to wait 2 Minutes to get the Message, that he isn't connected.

But I guess I have to live with that so far...


greetings

Posted: Mon Jan 09, 2006 1:18 pm
by Jorg
What I always do is provide a cancel possibility. I do my network I/O in a thread and when the user presses CANCEL in the GUI I provide SetCancel() to the thread that cancels. Ofcourse the thread needs to have no blocking I/O or else you can wait for a long time.

Posted: Wed Jan 11, 2006 10:48 pm
by jsheets
Part of the problem is it is difficult to tell if you really are connected, DNS can be cached on the local machine or local DNS servers, you can be connected to a LAN and able to access local resources and the main connection can still be down.

Even if the connection is up on a local machine it is possible the Internet host used in verification will be down, which could generate a false "not connected" response.

You can try:

#1 Opening a TCP/IP socket to a service that should be available if you are connected. If the connection times out before it succeeds you can assume either the host is down or for some reason you can't connect, possibly because you aren't connected to the Internet.

#2 Similar to above you can ping a host that either needs to be available for your application to work or one you believe will always be available.

Obviously if the server you are connecting to is unavailable it could tell you it couldn't connect. This isn't as big of an issue if the server connect to is the same server you want to connect to if you are online.

Any of these solutions have the potential to irritate the sever administrator if you aren't building a client / server solution and just want to know if your user is connected to the Internet.

You might also consider shorter timeouts.