Communication between a PHP service an Android device -


i wonder if there way in php, know if android device connected network, or wifi, ping device or that. idea? thanks.

the question seems broad right i'd use 1 of these 2 approaches:

1) if need test remote server using php, use socket php side. make android device accept connections server , once establish socket, you'll know if it's up/down.

2) easier approach establishing socket directly android device , if can establish it, send status remote server. 1 way setting socket against google, this:

you may declare socket. use following code on many of projects , timeout works.

socket socket; final string host = "www.google.com"; final int port = 80; final int timeout = 30000;   // 30 seconds  try {   socket = new socket();   socket.connect(new inetsocketaddress(host, port), timeout); } catch (unknownhostexception uhe) {   log.e("googlesock", "i couldn't resolve host you've provided, i'm having connection issue!"); } catch (sockettimeoutexception ste) {   log.e("googlesock", "after reasonable amount of time, i'm not able connect, connection down!"); } catch (ioexception ioe) {   log.e("googlesock", "hmmm... sudden disconnection, should start again!"); } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -