public static InetAddress getLocalIPFromServerSocket ( final int port , final int backlog ) throws UnknownHostException , IOException { InetAddress inetAddress = null ; ServerSocket socket = null ; try { socket = new ServerSocket ( port , backlog , InetAddress . getLocalHost ( ) ) ; inetAddress = socket . getInetAddress ( ) ; socket . close ( ) ; } finally { SocketExtensions . closeServerSocket ( socket ) ; } return inetAddress ; }
Gets the InetAddress object from the local host from a ServerSocket object .