rest - Check if RESTful server is available on Android -


i'm developping android rest-api oriented application.

i need create method check whether server available or not. problem if use url.openstream() method, there's no way determine whether request successful or not.

is there way without need operate of performing full httpurlconnection , read return code?

  1. you can use tcp sockets

    socketaddress socketaddress = new inetsocketaddress(address, port); try {     int timeout = 2000;     socket.connect(socketaddress, timeout); } catch (ioexception e) {       return false;  } {     if (socket.isconnected()) {         try {             socket.close();         }         catch (ioexception e) {             e.printstacktrace();         }     } } 

Comments

Popular posts from this blog

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -

How to run C# code using mono without Xamarin in Android? -