public static Keeper getRandomAvailablePortKeeper(int protocol, InetAddress addr) { int maxTries = 10000; while (maxTries-- > 0) { int port = getRandomWildcardBindPortNumber(); Keeper result = isPortKeepable(port, protocol, addr); if (result != null) { return result; } } throw new IllegalStateException("Cannot find an available port for protocol=" + protocol + " address=" + addr); }
public static Keeper getRandomAvailablePortKeeper(int protocol, InetAddress addr) { while (true) { int port = getRandomWildcardBindPortNumber(); Keeper result = isPortKeepable(port, protocol, addr); if (result != null) { return result; } } }
/** * Returns a randomly selected available port in the range 5001 to * 32767 that satisfies a modulus and the provided protocol * * @param protocol * The protocol to check (either {@link #SOCKET} or {@link * #MULTICAST}). * @param addr the bind-address or mcast address to use * * @throws IllegalArgumentException * <code>protocol</code> is unknown */ public static int getRandomAvailablePortWithMod(int protocol, InetAddress addr,int mod) { while (true) { int port = getRandomWildcardBindPortNumber(); if (isPortAvailable(port, protocol, addr) && (port % mod)==0) { return port; } } }
/** * Returns a randomly selected available port in the range 5001 to * 32767 that satisfies a modulus and the provided protocol * * @param protocol * The protocol to check (either {@link #SOCKET} or {@link * #JGROUPS}). * @param addr the bind-address or mcast address to use * * @throws IllegalArgumentException * <code>protocol</code> is unknown */ public static int getRandomAvailablePortWithMod(int protocol, InetAddress addr, int mod) { int maxTries = 10000; while (maxTries-- > 0) { int port = getRandomWildcardBindPortNumber(); if (isPortAvailable(port, protocol, addr) && (port % mod)==0) { return port; } } throw new IllegalStateException("Cannot find an available port for protocol=" + protocol + " address=" + addr + " mod=" + mod); }
/** * Returns a randomly selected available port in the range 5001 to * 32767. * * @param protocol * The protocol to check (either {@link #SOCKET} or {@link * #MULTICAST}). * @param addr the bind-address or mcast address to use * * @throws IllegalArgumentException * <code>protocol</code> is unknown */ public static int getRandomAvailablePort(int protocol, InetAddress addr) { while (true) { int port = getRandomWildcardBindPortNumber(); if (isPortAvailable(port, protocol, addr)) { // don't return the products default multicast port if ( !(protocol == MULTICAST && port == DistributionConfig.DEFAULT_MCAST_PORT) ){ return port; } } } } public static Keeper getRandomAvailablePortKeeper(int protocol, InetAddress addr) {
/** * Returns a randomly selected available port in the range 5001 to * 32767. * * @param protocol * The protocol to check (either {@link #SOCKET} or {@link * #JGROUPS}). * @param addr the bind-address or mcast address to use * * @throws IllegalArgumentException * <code>protocol</code> is unknown */ public static int getRandomAvailablePort(int protocol, InetAddress addr) { int maxTries = 10000; while (maxTries-- > 0) { int port = getRandomWildcardBindPortNumber(); if (isPortAvailable(port, protocol, addr)) { return port; } } throw new IllegalStateException("Cannot find an available port for protocol=" + protocol + " address=" + addr); } public static Keeper getRandomAvailablePortKeeper(int protocol, InetAddress addr) {