lua-users home
lua-l archive

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


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?
> > Should I simply try to connect to a server or is there a better way to do
> > this?
> >
> > Tks,
> >
> > Andreas
> >
> >
>
> Probably you want to try to connect to something. You can't really say
> a connection is up or not... they might have a good connection to
> their LAN, but that LAN doesn't have access to the internet. Or even
> the ISP has troubles (or the user lives in a country that censors
> websites) and not all of the internet is reachable at the moment...
>
> If you want to connect to a specific server, don't bother trying to
> check for all possible problems that could prevent it; just try, and
> report anything that goes wrong. If you just want to inform the user
> whether their connection seems to be working or not, the best way
> would be to try to ping a few hosts that aren't likely to all fail at
> once (google.com, microsoft.com, etc) and see if you can get through
> to any of them.

You can try to ping 8.8.8.8, which is the address of Google DNS...
  E.