Android HTTP Connection

Posted by Ubersoldat on Stack Overflow See other posts from Stack Overflow or by Ubersoldat
Published on 2009-01-14T10:11:49Z Indexed on 2010/04/01 5:33 UTC
Read the original article Hit count: 232

Can anybody tell my why this doesn't work in the Android emulator? From the browser I have access and the server is internal. All I can think of is that I'm missing some configuration on my app so it can access the network layer.

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");
}

Throws an UnknownHostException

Thanks

© Stack Overflow or respective owner

Related posts about android

Related posts about socket