public static InetAddress determineBindAddressBasedOnWifiP2pSubnet( ArrayList<InetAddress> localIpAddresses, InetAddress destAddress) { int byteArrayToInt = TypeConversion.byteArrayToInt(destAddress.getAddress()); for (InetAddress inetAddress : localIpAddresses) { if ((TypeConversion.byteArrayToInt(inetAddress.getAddress()) & WIFI_P2P_SUBNET_MASK) == (byteArrayToInt & WIFI_P2P_SUBNET_MASK)) { return inetAddress; } } return Network.getLoopbackAddress(); }
public static InetAddress determineBindAddressBasedOnWifiP2pSubnet( ArrayList<InetAddress> localIpAddresses, InetAddress destAddress) { int byteArrayToInt = TypeConversion.byteArrayToInt(destAddress.getAddress()); Iterator it = localIpAddresses.iterator(); while (it.hasNext()) { InetAddress inetAddress = (InetAddress) it.next(); if ((TypeConversion.byteArrayToInt(inetAddress.getAddress()) & WIFI_P2P_SUBNET_MASK) == (byteArrayToInt & WIFI_P2P_SUBNET_MASK)) { return inetAddress; } } return Network.getLoopbackAddress(); }
public static InetAddress determineBindAddressBasedOnIsReachable( ArrayList<InetAddress> localIpAddresses, InetAddress destAddress) { for (InetAddress inetAddress : localIpAddresses) { try { if (inetAddress.isReachable(NetworkInterface.getByInetAddress(inetAddress), TTL, TIMEOUT)) { return inetAddress; } } catch (SocketException e) { RobotLog.v( String.format( "socket exception while trying to get network interface of %s", inetAddress.getHostAddress())); } catch (IOException e2) { RobotLog.v( String.format( "IO exception while trying to determine if %s is reachable via %s", destAddress.getHostAddress(), inetAddress.getHostAddress())); } } return Network.getLoopbackAddress(); }
public static InetAddress determineBindAddressBasedOnIsReachable( ArrayList<InetAddress> localIpAddresses, InetAddress destAddress) { Iterator it = localIpAddresses.iterator(); while (it.hasNext()) { InetAddress inetAddress = (InetAddress) it.next(); try { if (inetAddress.isReachable(NetworkInterface.getByInetAddress(inetAddress), TTL, TIMEOUT)) { return inetAddress; } } catch (SocketException e) { RobotLog.m254v( String.format( "socket exception while trying to get network interface of %s", new Object[] {inetAddress.getHostAddress()})); } catch (IOException e2) { RobotLog.m254v( String.format( "IO exception while trying to determine if %s is reachable via %s", new Object[] {destAddress.getHostAddress(), inetAddress.getHostAddress()})); } } return Network.getLoopbackAddress(); }