I am trying to check rechability of host by following code :
Socket socket = new Socket();
try
{
SocketAddress socketAddress = new InetSocketAddress(InetAddress.getByName("https://www.google.co.in"), 80);
socket.connect(socketAddress, 2000);
}
catch (IOException e)
{
Log.e("server",e.getMessage());
return false;
}
finally
{
if (socket.isConnected()) {
try {
socket.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
return true;
but it always returns false. is there anything else that needs to be added. It gives unresolved host url exception.