API Call to check if device is connected to the internet?

Hi,

This is a simple question, I want to know if the device has an internet connection. Is there an API call (or any other call) to check if the device my Corona game is running on has an internet connection?

Thanks.

No, but there are a lot of solutions out there.  
 
For example, you can grab the code for ssk.misc.isConnectedToWWW()  from SSK.
 
This is the source to ssk.misc.*
 
https://github.com/roaminggamer/SSK2/blob/master/ssk2/misc.lua
 
The exact code is here:

local socket = require "socket" local isConnectedToWWW = function( url ) url = url or "www.google.com" local hostFound = true local con = socket.tcp() con:settimeout( 2 ) -- Timeout connection attempt after 2 seconds -- Check if socket connection is open if con:connect(url, 80) == nil then hostFound = false end return hostFound end

Note: Many times, if the solution is not in Corona I’ve written it in SSK or as part of one of my git repositories:

No, but there are a lot of solutions out there.  
 
For example, you can grab the code for ssk.misc.isConnectedToWWW()  from SSK.
 
This is the source to ssk.misc.*
 
https://github.com/roaminggamer/SSK2/blob/master/ssk2/misc.lua
 
The exact code is here:

local socket = require "socket" local isConnectedToWWW = function( url ) url = url or "www.google.com" local hostFound = true local con = socket.tcp() con:settimeout( 2 ) -- Timeout connection attempt after 2 seconds -- Check if socket connection is open if con:connect(url, 80) == nil then hostFound = false end return hostFound end

Note: Many times, if the solution is not in Corona I’ve written it in SSK or as part of one of my git repositories: