/** * Obtains the {@link InetAddress} on which the {@link SocketBasedRemoteChannelServer} * will accept connections (based on a specific {@link Predicate}) * * @param predicate the {@link Predicate} to filter {@link InetAddress}es * (or <code>null</code> indicating the default is acceptable) * * @return the {@link InetAddress} */ public synchronized InetAddress getInetAddress(Predicate<InetAddress> predicate) { if (serverSocket != null) { try { predicate = predicate == null ? NetworkHelper.DEFAULT_ADDRESS : predicate; InetAddress inetAddress = NetworkHelper.getInetAddress(predicate); // when the specific inetAddess is not available, use the server socket return inetAddress == null ? serverSocket.getInetAddress() : inetAddress; } catch (SocketException e) { return serverSocket.getInetAddress(); } } else { throw new IllegalStateException("Server is closed"); } }
/** * Obtains the {@link InetAddress} on which the {@link SocketBasedRemoteChannelServer} * will accept connections (based on a specific {@link Predicate}) * * @param predicate the {@link Predicate} to filter {@link InetAddress}es * (or <code>null</code> indicating the default is acceptable) * * @return the {@link InetAddress} */ public synchronized InetAddress getInetAddress(Predicate<InetAddress> predicate) { if (serverSocket != null) { try { predicate = predicate == null ? NetworkHelper.DEFAULT_ADDRESS : predicate; InetAddress inetAddress = NetworkHelper.getInetAddress(predicate); // when the specific inetAddess is not available, use the server socket return inetAddress == null ? serverSocket.getInetAddress() : inetAddress; } catch (SocketException e) { return serverSocket.getInetAddress(); } } else { throw new IllegalStateException("Server is closed"); } }