有人能告诉我为什么这在Android模拟器中不起作用吗?从浏览器中我可以访问,而服务器是内部的。我想到的唯一可能是我在应用程序中缺少一些配置,以便它可以访问网络层。
try {
InetAddress server = Inet4Address.getByName("thehost");
//Doesn't work either
//or InetAddress server2 = Inet4Address.getByAddress(new String("192.168.1.30").getBytes());
if(server.isReachable(5000)){
Log.d(TAG, "Ping!");
}
Socket clientsocket = new Socket(server, 8080);
} catch (UnknownHostException e) {
Log.e(TAG, "Server Not Found");
} catch (IOException e) {
Log.e(TAG, "Couldn't open socket");
}
抛出一个UnknownHostException异常
谢谢