1

I'm trying to create a server that will host a game that can be played with android devices in the same network. I create the server like this

InetAddress addr = InetAddress.getLocalHost();
server = new ServerSocket(4456,50,addr);
System.out.println(server.getInetAddress());

and when i print the ip, i get 192.168.1.7. The problem is that when i use getLocalHost(); on Android emulator(the one that comes with Android Studio)or a normal android device, the ip i get is 127.0.0.1 How can i get the localHost ip from the server that is hosted on Windows?

nunak boss
  • 11
  • 1
  • Possible duplicate of [Getting the IP address of the current machine using Java](http://stackoverflow.com/questions/9481865/getting-the-ip-address-of-the-current-machine-using-java) – N J Jun 05 '16 at 02:00
  • As far as I remember the localhost address for the windows server is `10.0.2.2` for the emulator. – Sourav Kanta Jun 05 '16 at 06:32

0 Answers0