How do you test a network connection?

Need to fetch a file from a server that is inside a private LAN. I need a quick way to test to see if the user can access the server. Does anyone know how to do this other than letting the file fetch timeout?

Thanks,

Dave [import]uid: 18679 topic_id: 5379 reply_id: 305379[/import]

Anyone have a way of doing this? Currently it locks the app while the file transfer times out. Need to find a way to test the connection prior to copying the file.

HELP…

Thanks [import]uid: 18679 topic_id: 5379 reply_id: 19413[/import]

Well, the search function is your friend, you know :wink:

[lua]local http = require(“socket.http”)
local ltn12 = require(“ltn12”)

–****************************************************************
function check_conn()
–****************************************************************
local answer={} – This contains text web page (or other output from server), if it found
local error=“Network OK”

local wawurl=“http://www.google.com” – or other site, of course
local c,r=http.request{
url = wawurl,
sink = ltn12.sink.table(answer)
}
if r==“host not found” then
error=r
end
if (r~=200 and r~=“host not found”) then
error="HTTP error "…r
end
return error
end[/lua]

I hope that helps. Just change the IP to a local one.

Cheers
Michael

http://www.whiteskygames.com
http://www.twitter.com/mhartlef
[import]uid: 5712 topic_id: 5379 reply_id: 19415[/import]

Thanks!!! [import]uid: 18679 topic_id: 5379 reply_id: 19420[/import]

Thanks!!! [import]uid: 18679 topic_id: 5379 reply_id: 19421[/import]