This is pretty much straight forward
Socket socket = new Socket();
socket.connect(new InetSocketAddress(host, port), Utilities.TCP_SOCKET_TIMEOUT_MS);
socket.close();
Now catch TimeoutException or Connect Exception and if that does not happen in given timeout ms, exception will be thrown
References:
https://stackoverflow.com/questions/8105290/checking-if-server-port-is-open-from-android
Socket socket = new Socket();
socket.connect(new InetSocketAddress(host, port), Utilities.TCP_SOCKET_TIMEOUT_MS);
socket.close();
Now catch TimeoutException or Connect Exception and if that does not happen in given timeout ms, exception will be thrown
References:
https://stackoverflow.com/questions/8105290/checking-if-server-port-is-open-from-android
No comments:
Post a Comment