/** * Test to see if a given port is available port on all interfaces on this host. * @param port * @return true of if the port is free on all interfaces */ private static boolean testAllInterfaces(int port) { Keeper k = keepAllInterfaces(port); if (k != null) { k.release(); return true; } else { return false; } } private static Keeper keepAllInterfaces(int port) {
/** * Test to see if a given port is available port on all interfaces on this host. * @param port * @return true of if the port is free on all interfaces */ private static boolean testAllInterfaces(int port) { Keeper k = keepAllInterfaces(port); if (k != null) { k.release(); return true; } else { return false; } } private static Keeper keepAllInterfaces(int port) {
public static Keeper isPortKeepable(final int port, int protocol, InetAddress addr) { if (protocol == SOCKET) { // Try to create a ServerSocket if(addr == null) { return keepAllInterfaces(port); } else { return keepOneInterface(addr, port); } } else if (protocol == JGROUPS) { throw new IllegalArgumentException("You can not keep the JGROUPS protocol"); } else { throw new IllegalArgumentException(LocalizedStrings.AvailablePort_UNKNOWN_PROTOCOL_0.toLocalizedString(Integer.valueOf(protocol))); } }
public static Keeper isPortKeepable(final int port, int protocol, InetAddress addr) { if (protocol == SOCKET) { // Try to create a ServerSocket if(addr == null) { return keepAllInterfaces(port); } else { return keepOneInterface(addr, port); } } else if (protocol == MULTICAST) { throw new IllegalArgumentException("You can not keep the JGROUPS protocol"); } else { throw new IllegalArgumentException(LocalizedStrings.AvailablePort_UNKNOWN_PROTOCOL_0.toLocalizedString(Integer.valueOf(protocol))); } }