I'm trying to deal with a problem, which is a known issue, but I couldn't find any reply to this so far. I have an Android application (which I run on an emulator within Eclipse) and I need to perform a socket communication with a Java server appliaction running on the same computer. It won't connect. The server is running properly (has been tested), but the client (android app) can't connect to the server in any case. Can you recommend what to try? I know I cannot use "localhost" or 127.0.0.1 as it refers to the emulator's loopback, not the computer's one. Yet, no other IP address I pass to the Socket constructor works.
This is my Android client app's attempt to connect:
Socket connection = new Socket(InetAddress.getByName("anything"), 12345);
- if I put "localhost" or 127.0.0.1 instead of "anything" I obviously end up with "connection refused" exception.
- if I put any number as IP address (either directly here or via InetAddress.getByAddress()) the app halts and the log says "launch timeout has expired. giving up wake lock" and does not proceed any further. I tried random addresses, my ethernet NIC's address (which is pingable) and nothing works.
I can't get through this. Any advice would be appreciated!