The way I’m detecting an internet connection now is like this:
local http = require("socket.http")
local ltn12 = require("ltn12")
local network = false
local r,e= http.request( "http://www.microsoft.com" )
if(r) then
network = true
end
I used microsoft.com because they have the best uptime of anyone I could think of on short notice, and they wouldn’t be blocked in any countries (as far as i know…).
But of course making an entire get request to someone else’s domain and then reading the whole http response (60kb in this case) seems like a pretty hacky solution.
I see that the network api has the following method: network.setStatusListener(), but this does not seem suitable because I want to know if the user has a connection in the first place (Not if their connection status changes in the future).
Anyone have a better way? [import]uid: 135827 topic_id: 33471 reply_id: 333471[/import]
