lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Feb 12, 2012 9:20 AM, "Eduardo Ochs" <eduardoochs@gmail.com> wrote:
>
> On Sun, Feb 12, 2012 at 7:55 AM, HyperHacker <hyperhacker@gmail.com> wrote:
> >
> > On Sun, Feb 12, 2012 at 02:45, Andreas Falkenhahn
> > <andreas@falkenhahn.com> 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 8.8.8.8, which is the address of Google DNS...

Could get weird in IPv6 environments, will break behind some firewalls. Slightly safer to ask 8.8.8.8 to resolve something.

If you want "is there an IPv4 network interface with a default route" sending a packet with TTL 1 to 8.8.8.8 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[1] 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?

Jay

[1]: oooh, we're not stuck in ASCII this week. "Þe Olde ZoneAlarm".