Checking for Wi-Fi connection

Hello,

Is there a way to check if the device is connected to the internet via Wi-Fi ??

thanks [import]uid: 185094 topic_id: 33459 reply_id: 333459[/import]

I do not believe this is possible at the current time, although you can check if they are connected to the internet. (Via WiFi, 3G, 4G, etc.)

Would that be useful or is this WiFi specific? [import]uid: 52491 topic_id: 33459 reply_id: 132984[/import]

If just checking your connection to the web is enough, this code should do it:
[lua]local socket = require “socket”
function networking:isConnectedToWWW( url )
local 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
print( "URL Not Found: " … url )
else
print( "URL Found: " … url )
end

return hostFound
end[/lua]

As far as checking if the connection is specifically Wi-Fi, this won’t tell you that. Also, if you don’t like this code, there are several solutions out there.
[import]uid: 110228 topic_id: 33459 reply_id: 133012[/import]

@emaurina,
I believe the code I provided in the following thread can detect Wi-Fi connectivity, but I haven’t tested it exhaustively (it works on my devices, using Wi-Fi, but I haven’t tested it across 10 different devices and OS versions or anything like that).

What do you think, based on the code do you think this is correct?

http://developer.coronalabs.com/forum/2012/11/30/best-method-detecting-internet-connection

Brent
[import]uid: 200026 topic_id: 33459 reply_id: 133039[/import]

i just needed a simple code for checking internet connection… i need it to be fast and to work on all devices… [import]uid: 185094 topic_id: 33459 reply_id: 133046[/import]

I do not believe this is possible at the current time, although you can check if they are connected to the internet. (Via WiFi, 3G, 4G, etc.)

Would that be useful or is this WiFi specific? [import]uid: 52491 topic_id: 33459 reply_id: 132984[/import]

If just checking your connection to the web is enough, this code should do it:
[lua]local socket = require “socket”
function networking:isConnectedToWWW( url )
local 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
print( "URL Not Found: " … url )
else
print( "URL Found: " … url )
end

return hostFound
end[/lua]

As far as checking if the connection is specifically Wi-Fi, this won’t tell you that. Also, if you don’t like this code, there are several solutions out there.
[import]uid: 110228 topic_id: 33459 reply_id: 133012[/import]

@emaurina,
I believe the code I provided in the following thread can detect Wi-Fi connectivity, but I haven’t tested it exhaustively (it works on my devices, using Wi-Fi, but I haven’t tested it across 10 different devices and OS versions or anything like that).

What do you think, based on the code do you think this is correct?

http://developer.coronalabs.com/forum/2012/11/30/best-method-detecting-internet-connection

Brent
[import]uid: 200026 topic_id: 33459 reply_id: 133039[/import]

i just needed a simple code for checking internet connection… i need it to be fast and to work on all devices… [import]uid: 185094 topic_id: 33459 reply_id: 133046[/import]