diff --git a/junixsocket-common/src/test/java/org/newsclub/net/unix/java/JavaAddressSpecifics.java b/junixsocket-common/src/test/java/org/newsclub/net/unix/java/JavaAddressSpecifics.java index c3c0efa9d..2e9dd92c9 100644 --- a/junixsocket-common/src/test/java/org/newsclub/net/unix/java/JavaAddressSpecifics.java +++ b/junixsocket-common/src/test/java/org/newsclub/net/unix/java/JavaAddressSpecifics.java @@ -116,7 +116,8 @@ public CloseablePair newDatagramSocketPair() throws I @Override public ServerSocket newServerSocketBindOn(SocketAddress addr) throws IOException { InetSocketAddress inetAddr = (InetSocketAddress) addr; - if (!inetAddr.getAddress().isAnyLocalAddress()) { + InetAddress address = inetAddr.getAddress(); + if (!address.isAnyLocalAddress() && !address.isLoopbackAddress()) { throw new IllegalArgumentException("Not a local address: " + inetAddr); } return new ServerSocket(inetAddr.getPort()); @@ -132,7 +133,8 @@ public Socket connectTo(SocketAddress addr) throws IOException { public ServerSocket newServerSocketBindOn(SocketAddress addr, boolean deleteOnClose) throws IOException { InetSocketAddress inetAddr = (InetSocketAddress) addr; - if (!inetAddr.getAddress().isAnyLocalAddress()) { + InetAddress address = inetAddr.getAddress(); + if (!address.isAnyLocalAddress() && !address.isLoopbackAddress()) { throw new IllegalArgumentException("Not a local address: " + inetAddr); } return new ServerSocket(inetAddr.getPort());