Check Internet Connection
-
- Earned some good credits
- Posts: 135
- Joined: Thu Apr 28, 2005 11:36 am
- Location: Gie
Check Internet Connection
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
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
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Re: Check Internet Connection
PossiblyMuskelkatermann wrote: But I guess there is a better way!
How would you solve the Problem?
Greetings
Code: Select all
wxDialUpManager::IsOnline
[Mostly retired moderator, still check in to clean up some stuff]
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
Please, browse "wx\samples\dialup" sample.
- T U R K E Y ?
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
-
- Earned some good credits
- Posts: 135
- Joined: Thu Apr 28, 2005 11:36 am
- Location: Gie
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
Not only dialup connection. it works for DSL.
- T U R K E Y ?
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
-
- Earned some good credits
- Posts: 135
- Joined: Thu Apr 28, 2005 11:36 am
- Location: Gie
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
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
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
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- Earned some good credits
- Posts: 135
- Joined: Thu Apr 28, 2005 11:36 am
- Location: Gie
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
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
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.
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
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.
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.