private int tryOpenServerSocketChannel(InetAddress bindAddress, int initialPort, int portTrialCount, boolean bindAny) throws IOException { assert portTrialCount > 0 : "Port trial count must be positive: " + portTrialCount; IOException error = null; for (int i = 0; i < portTrialCount; i++) { int actualPort = initialPort + i; boolean reuseAddress = networkConfig.isReuseAddress(); InetSocketAddress socketBindAddress = bindAny ? new InetSocketAddress(actualPort) : new InetSocketAddress(bindAddress, actualPort); try { return openServerSocketChannel(socketBindAddress, reuseAddress); } catch (IOException e) { error = e; } } throw error; }
return tryOpenServerSocketChannel(bindAddress, initialPort, portTrialCount, bindAny); } catch (IOException e) { String message = "Cannot bind to a given address: " + bindAddress + ". Hazelcast cannot start. ";
return tryOpenServerSocketChannel(bindAddress, initialPort, portTrialCount, bindAny); } catch (IOException e) { String message = "Cannot bind to a given address: " + bindAddress + ". Hazelcast cannot start. ";
private int tryOpenServerSocketChannel(InetAddress bindAddress, int initialPort, int portTrialCount, boolean bindAny) throws IOException { assert portTrialCount > 0 : "Port trial count must be positive: " + portTrialCount; IOException error = null; for (int i = 0; i < portTrialCount; i++) { int actualPort = initialPort + i; boolean reuseAddress = networkConfig.isReuseAddress(); InetSocketAddress socketBindAddress = bindAny ? new InetSocketAddress(actualPort) : new InetSocketAddress(bindAddress, actualPort); try { return openServerSocketChannel(socketBindAddress, reuseAddress); } catch (IOException e) { error = e; } } throw error; }