1. How detect internet connection?

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?

new topic     » topic index » view message » categorize

2. Re: How detect internet connection?

sergelli said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: How detect internet connection?

useless_ said...

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: How detect internet connection?

sergelli said...
eukat said...

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.

new topic     » goto parent     » topic index » view message » categorize

5. Re: How detect internet connection?

jimcbrown said...

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?

new topic     » goto parent     » topic index » view message » categorize

6. Re: How detect internet connection?

sergelli said...

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 
new topic     » goto parent     » topic index » view message » categorize

7. Re: How detect internet connection?

That's a Linux solution. Is it?

But what is the solution to poor little Windows? :)

new topic     » goto parent     » topic index » view message » categorize

8. Re: How detect internet connection?

sergelli said...

That's a Linux solution. Is it?

Nixland - it's not Linux/GNU specific.

sergelli said...

But what is the solution to poor little Windows? :)

Oh, it's off by one character. tongue

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 
new topic     » goto parent     » topic index » view message » categorize

9. Re: How detect internet connection?

Now worked! Even within a Linux system using wine.

Thank you Jim

new topic     » goto parent     » topic index » view message » categorize

10. Re: How detect internet connection?

Oops ... I spoke too soon in victory ...

The answer is always zero, even if I use a non-existent address or disconnect the internet

new topic     » goto parent     » topic index » view message » categorize

11. Re: How detect internet connection?

sergelli said...

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.

new topic     » goto parent     » topic index » view message » categorize

12. Re: How detect internet connection?

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu