title: Socket program for Server using System IP Address
body: <p>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,</p>
  
  <pre><code>InetAddress inetAddress = InetAddress.getLocalHost();
  ServerSocket serverSocket;
  if (serverSocket == null)
  serverSocket = new ServerSocket(1000, 0, inetAddress);
  Socket socket=serverSocket.accept();
  </code></pre>
  
  <p>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,</p>
  
  <pre><code>System.out.println(inetAddress.getHostAddress);
  </code></pre>
  
  <p>in Windows OS correct IP address gets printed but in Unix OS, what I got was</p>
  
  <blockquote>
    <p>127.0.0.1</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>Thanks.</p>