I have Android client app that communicates with server using Socket
.
On my development machine, SocketServer
(server is also written in Java) is listening at 127.0.1.1
at port 8666
. I also have added Internet access permissions in App manifest of Android app.
But when I attempt to instantiate Socket object using client = new Socket("127.0.1.1",8666)
, it throws IOException
with connection refused
message (also tried using localhost
instead of manually giving IP address, but it doesn't work as well). While I can easily connect to server from simple console Java program.
What could be wrong here?
Update
My question in some ways relates to this. I AM attempting to access a server running in the machine same in which emulator is running.
Note: I know its not recommended to perform network IOs in any Activity class, and I'm not doing that way either, above code is just a problem simplified to understand.