I'm trying to run a server application in PC using ServerSocket, for that I trying to get the system's IP address to start the server and to wait for client to connect, for that I've written,
InetAddress inetAddress = InetAddress.getLocalHost();
ServerSocket serverSocket;
if (serverSocket == null)
serverSocket = new ServerSocket(1000, 0, inetAddress);
Socket socket=serverSocket.accept();
Its working correctly in the Window OS, when I try this application in Unix OS its not working for me, I tried to print the IP address using,
System.out.println(inetAddress.getHostAddress);
in Windows OS correct IP address gets printed but in Unix OS, what I got was
127.0.0.1
so the server is not working, I have not tried this in Mac OS, so is there any way to start the server using the system's default IP address in any OS.
Thanks.