Java Code Examples for java.net.NetworkInterface#equals()
The following examples show how to use
java.net.NetworkInterface#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Inet6AddressSerializationTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 2
Source File: SetGetNetworkInterfaceTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 3
Source File: Inet6AddressSerializationTest.java From hottub with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 4
Source File: SetGetNetworkInterfaceTest.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 5
Source File: Inet6AddressSerializationTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 6
Source File: Inet6AddressSerializationTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 7
Source File: Inet6AddressSerializationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 8
Source File: SetGetNetworkInterfaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 9
Source File: Inet6AddressSerializationTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 10
Source File: SetGetNetworkInterfaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 11
Source File: SetGetNetworkInterfaceTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 12
Source File: SetGetNetworkInterfaceTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 13
Source File: NioDatagramChannel.java From netty4.0.27Learn with Apache License 2.0 | 5 votes |
@Override public ChannelFuture leaveGroup( InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) { checkJavaVersion(); if (multicastAddress == null) { throw new NullPointerException("multicastAddress"); } if (networkInterface == null) { throw new NullPointerException("networkInterface"); } synchronized (this) { if (memberships != null) { List<MembershipKey> keys = memberships.get(multicastAddress); if (keys != null) { Iterator<MembershipKey> keyIt = keys.iterator(); while (keyIt.hasNext()) { MembershipKey key = keyIt.next(); if (networkInterface.equals(key.networkInterface())) { if (source == null && key.sourceAddress() == null || source != null && source.equals(key.sourceAddress())) { key.drop(); keyIt.remove(); } } } if (keys.isEmpty()) { memberships.remove(multicastAddress); } } } } promise.setSuccess(); return promise; }
Example 14
Source File: SetGetNetworkInterfaceTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 15
Source File: Inet6AddressSerializationTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 16
Source File: SetGetNetworkInterfaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { boolean passed = true; try { MulticastSocket ms = new MulticastSocket(); Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface netIf = networkInterfaces.nextElement(); if (isNetworkInterfaceTestable(netIf)) { printNetIfDetails(netIf); ms.setNetworkInterface(netIf); NetworkInterface msNetIf = ms.getNetworkInterface(); if (netIf.equals(msNetIf)) { System.out.println(" OK"); } else { System.out.println("FAILED!!!"); printNetIfDetails(msNetIf); passed = false; } System.out.println("------------------"); } } } catch (IOException e) { e.printStackTrace(); passed = false; } if (!passed) { throw new RuntimeException("Test Fail"); } System.out.println("Test passed "); }
Example 17
Source File: NioDatagramChannel.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
/** * Block the given sourceToBlock address for the given multicastAddress on the given networkInterface */ @Override public ChannelFuture block( InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise) { checkJavaVersion(); if (multicastAddress == null) { throw new NullPointerException("multicastAddress"); } if (sourceToBlock == null) { throw new NullPointerException("sourceToBlock"); } if (networkInterface == null) { throw new NullPointerException("networkInterface"); } synchronized (this) { if (memberships != null) { List<MembershipKey> keys = memberships.get(multicastAddress); for (MembershipKey key: keys) { if (networkInterface.equals(key.networkInterface())) { try { key.block(sourceToBlock); } catch (IOException e) { promise.setFailure(e); } } } } } promise.setSuccess(); return promise; }
Example 18
Source File: Inet6AddressSerializationTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }
Example 19
Source File: IrisUpnpService.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override public void run() { try { log.trace("checking if upnp needs restart..."); // Update interface list List<String> lastInets = inets; inets = getInets(); boolean changed = false; if (!inets.equals(lastInets)) { changed = true; } // Run through list of inets even if list is different to update existing data for (String inet : inets) { NetworkInterface nif = findNetworkInterface(inet); InetAddress addr = findBestInet(nif); NetworkInterface existingNif = netInterfaces.put(inet, nif); InetAddress existingAddr = ipAddresses.put(inet, addr); if ((existingNif == null && nif != null) || (existingAddr == null && addr != null) || (existingNif != null && !existingNif.equals(nif)) || (existingAddr != null && !existingAddr.equals(addr))) { changed = true; } } if (changed) { restart(); } } catch (Exception th) { log.warn("failed to run upnp restart check", th); } }
Example 20
Source File: Inet6AddressSerializationTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static void assertNetworkInterfaceEqual( NetworkInterface expectedNetworkInterface, NetworkInterface deserializedNetworkInterface) { System.err .println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:"); if (expectedNetworkInterface == null) { if (deserializedNetworkInterface == null) { // ok, do nothing. System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } else { System.err.println("Error checking " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } } else if (!expectedNetworkInterface .equals(deserializedNetworkInterface)) { System.err.println("Error checking " + // versionStr + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); failed = true; } else { System.err.println("Network Interface equality " + " NetworkInterface, expected:" + expectedNetworkInterface + ", got :" + deserializedNetworkInterface); } }