Collection<Inet6Address> possibleInetAddresses = getPossibleInetAddressesFor((Inet6Address) inetAddress); for (Inet6Address inet6Address : possibleInetAddresses) { for (int i = 0; i < portTryCount; i++) {
final Collection<Inet6Address> possibleInetAddresses = getPossibleInetAddressesFor((Inet6Address) inetAddress); for (Inet6Address inet6Address : possibleInetAddresses) { for (int i = 0; i < portTryCount; i++) {
private void tryConnectToIPv6() throws Exception { Collection<Inet6Address> possibleInetAddresses = AddressUtil .getPossibleInetAddressesFor((Inet6Address) address.getInetAddress()); Level level = silent ? Level.FINEST : Level.INFO; //TODO: collection.toString() will likely not produce any useful output! if (logger.isLoggable(level)) { logger.log(level, "Trying to connect possible IPv6 addresses: " + possibleInetAddresses); } boolean connected = false; Exception error = null; int configuredTimeoutMillis = ioService.getSocketConnectTimeoutSeconds() * MILLIS_PER_SECOND; int timeoutMillis = configuredTimeoutMillis > 0 && configuredTimeoutMillis < Integer.MAX_VALUE ? configuredTimeoutMillis : DEFAULT_IPV6_SOCKET_CONNECT_TIMEOUT_SECONDS * MILLIS_PER_SECOND; for (Inet6Address inetAddress : possibleInetAddresses) { try { tryToConnect(new InetSocketAddress(inetAddress, address.getPort()), timeoutMillis); connected = true; break; } catch (Exception e) { error = e; } } if (!connected && error != null) { // could not connect any of addresses throw error; } }
private void tryConnectToIPv6() throws Exception { Collection<Inet6Address> possibleInetAddresses = AddressUtil .getPossibleInetAddressesFor((Inet6Address) address.getInetAddress()); Level level = silent ? Level.FINEST : Level.INFO; //TODO: collection.toString() will likely not produce any useful output! if (logger.isLoggable(level)) { logger.log(level, "Trying to connect possible IPv6 addresses: " + possibleInetAddresses); } boolean connected = false; Exception error = null; int configuredTimeoutMillis = ioService.getSocketConnectTimeoutSeconds() * MILLIS_PER_SECOND; int timeoutMillis = configuredTimeoutMillis > 0 && configuredTimeoutMillis < Integer.MAX_VALUE ? configuredTimeoutMillis : DEFAULT_IPV6_SOCKET_CONNECT_TIMEOUT_SECONDS * MILLIS_PER_SECOND; for (Inet6Address inetAddress : possibleInetAddresses) { try { tryToConnect(new InetSocketAddress(inetAddress, address.getPort()), timeoutMillis); connected = true; break; } catch (Exception e) { error = e; } } if (!connected && error != null) { // could not connect any of addresses throw error; } }