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" <> wrote:
> On Sun, Feb 12, 2012 at 7:55 AM, HyperHacker <> wrote:
> >
> > On Sun, Feb 12, 2012 at 02:45, Andreas Falkenhahn
> > <> 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, which is the address of Google DNS...

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

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


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