On Feb 12, 2012 9:20 AM, "Eduardo Ochs" <firstname.lastname@example.org> wrote:
> On Sun, Feb 12, 2012 at 7:55 AM, HyperHacker <email@example.com> wrote:
> > On Sun, Feb 12, 2012 at 02:45, Andreas Falkenhahn
> > <firstname.lastname@example.org> wrote:
> > >
> > > Hi,
> > >
> > > how would I check if an Internet connection is available using LuaSocket?
"Don't" is my advice. Look for a capability, or a prerequisite to that capability.
Even the second can be tricky. I was going to say "do a DNS lookup of your target" but that can be trouble in some proxied environments. A particular name may not be resolvable but be available through an HTTP or SOCKS5 proxy.
> You can try to ping 184.108.40.206, which is the address of Google DNS...
Could get weird in IPv6 environments, will break behind some firewalls. Slightly safer to ask 220.127.116.11 to resolve something.
If you want "is there an IPv4 network interface with a default route" sending a packet with TTL 1 to 18.104.22.168 might give you different flavors of failure. Any of these will set off various forms of intrusion detection and/or host-based firewalls like Ye Olde ZoneAlarm or Windows Firewall depending on policy.
Why yes, I *have* debugged Internet tools on a lot of really crappy nets in my life, why do you ask?
: oooh, we're not stuck in ASCII this week. "Þe Olde ZoneAlarm".