Code example for NetworkInterface

Methods: getInetAddresses

0
                theInterface.getInetAddresses().hasMoreElements());
        InetAddress firstAddress = (InetAddress) theInterface.getInetAddresses().nextElement();
        // validate we the first address in the network interface is the ANY address 
        assertTrue(firstAddress.isAnyLocalAddress());
 
        mss.setNetworkInterface(networkInterface1);
        assertEquals("getNetworkInterface did not return interface set by setNeworkInterface",
                networkInterface1, mss.getNetworkInterface());
 
        if (atLeastTwoInterfaces) {
            mss.setNetworkInterface(networkInterface2);
            assertEquals("getNetworkInterface did not return network interface set by second setNetworkInterface call",
                    networkInterface2, mss.getNetworkInterface());
        } 
        mss.close();
 
        groupPort = Support_PortManager.getNextPortForUDP();
        mss = new MulticastSocket(groupPort);
        if (IPV6networkInterface1 != null) {
            mss.setNetworkInterface(IPV6networkInterface1);
            assertEquals("getNetworkInterface did not return interface set by setNeworkInterface",
                    IPV6networkInterface1, mss.getNetworkInterface());