1. How detect internet connection?
- Posted by sergelli Aug 12, 2013
- 1778 views
How to detect in my program, if the internet connection is working?
I have used "c_func (InternetCheckConnection, {Voi1, FLAG_ICC_FORCE_CONNECTION, 0})", but after calling this command More times, the program stays locked for up to two minutes
Is there some way to prevent this crash?
There are other commands to detect internet connection?
2. Re: How detect internet connection?
- Posted by useless_ Aug 12, 2013
- 1739 views
How to detect in my program, if the internet connection is working?
I have used "c_func (InternetCheckConnection, {Voi1, FLAG_ICC_FORCE_CONNECTION, 0})", but after calling this command More times, the program stays locked for up to two minutes
Is there some way to prevent this crash?
There are other commands to detect internet connection?
Sure:
dns google.com. (your isp or computer may cache this tho)
http to google. (or anywhere else)
useless
3. Re: How detect internet connection?
- Posted by sergelli Aug 13, 2013
- 1707 views
Sure:
dns google.com. (your isp or computer may cache this tho)
http to google. (or anywhere else)
useless
When I try to do a "get dns google.com", the program stops responding for several seconds (if no internet). By using the http, this delay also happens.
This delay, I would like to avoid.
For this, I need a solely function to detect whether the internet is available
So, I would make a program ....
if hasInternet () then getDNS (MyISP) else - Do nothing end if
... and avoid the delay that I do not wish
4. Re: How detect internet connection?
- Posted by jimcbrown (admin) Aug 13, 2013
- 1704 views
Sure:
dns google.com. (your isp or computer may cache this tho)
http to google. (or anywhere else)
When I try to do a "get dns google.com", the program stops responding for several seconds (if no internet). By using the http, this delay also happens.
This delay, I would like to avoid.
For this, I need a solely function to detect whether the internet is available
So, I would make a program ....
if hasInternet () getDNS (MyISP) else - Do nothing end if
... and avoid the delay that I do not wish
It looks like, rather than simply wanting to doing something else while you are waiting (or having an asychronous notification), you want some kind of instantenous notification about the internet being down.
With TCP, this is not possible as the protocol mandates a minimum waiting time.
You could try something like "ping -c 1 -w 1 google.com", which uses ICMP and would return within 1 second - however it's possible for that to return a failure status when the internet connection (and connection to Google) is fully online but simply slow.
You could also parse the output of "ifconfig" and "route -n" to see if any network interfaces are configured and if the gateway is set, etc. If that's not the case, then the connection to the internet is definitely down - and you'd know it almost instantenously.
However, it's possible for those settings to be up and configured correctly, but for the internet connection itself to still be down. There's no surefire way to do this without waiting for a period of time.
5. Re: How detect internet connection?
- Posted by sergelli Aug 13, 2013
- 1671 views
However, it's possible for those settings to be up and configured correctly, but for the internet connection itself to still be down. There's no surefire way to do this without waiting for a period of time.
This is a problem, although it seems to be outside our purview.
When the connection is good, these functions (specific to detect the Internet) are quick to respond. But when the connection is bad, then there is a delay that can be great, and our program is locked. This is a nonsense, because we want to receive information, just as there is connection problems.
The solution using "ping" sounds good. But what is the function Euphoria to use this resource?
6. Re: How detect internet connection?
- Posted by jimcbrown (admin) Aug 13, 2013
- 1654 views
The solution using "ping" sounds good. But what is the function Euphoria to use this resource?
integer ping_retcode = system_exec("/bin/ping -c 1 -w 1 google.com", 2) if ping_retcode = 0 then -- internet connection good else -- internet connection possibly down end if
7. Re: How detect internet connection?
- Posted by sergelli Aug 13, 2013
- 1671 views
That's a Linux solution. Is it?
But what is the solution to poor little Windows? :)
8. Re: How detect internet connection?
- Posted by jimcbrown (admin) Aug 13, 2013
- 1642 views
That's a Linux solution. Is it?
Nixland - it's not Linux/GNU specific.
But what is the solution to poor little Windows? :)
Oh, it's off by one character.
integer ping_retcode = system_exec("ping -n 1 -w 1 google.com", 2) if ping_retcode = 0 then -- internet connection good else -- internet connection possibly down end if
9. Re: How detect internet connection?
- Posted by sergelli Aug 13, 2013
- 1606 views
Now worked! Even within a Linux system using wine.
Thank you Jim
10. Re: How detect internet connection?
- Posted by sergelli Aug 13, 2013
- 1668 views
Oops ... I spoke too soon in victory ...
The answer is always zero, even if I use a non-existent address or disconnect the internet
11. Re: How detect internet connection?
- Posted by jimcbrown (admin) Aug 13, 2013
- 1640 views
Oops ... I spoke too soon in victory ...
The answer is always zero, even if I use a non-existent address or disconnect the internet
Have you tried bumping the timeout? To e.g. -w 1000 ?
If it's just the exit code that's wrong, you can use pipeio to parse the output of the ping command itself.
12. Re: How detect internet connection?
- Posted by DonCole Aug 14, 2013
- 1624 views
I use http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=urlmon for this sort of thing.
Don Cole