test/java/net/MulticastSocket/SetOutgoingIf.java

Print this page

        

@@ -25,11 +25,10 @@
  * @test
  * @bug 4742177
  * @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
  */
 import java.net.*;
-import java.util.concurrent.*;
 import java.util.*;
 
 
 public class SetOutgoingIf {
     private static int PORT = 9001;

@@ -68,11 +67,12 @@
 
         // We need 2 or more network interfaces to run the test
         //
         List<NetworkInterface> nics = new ArrayList<NetworkInterface>();
         for (NetworkInterface nic : Collections.list(NetworkInterface.getNetworkInterfaces())) {
-            if (!nic.isLoopback())
+            // we should use only network interfaces with multicast support which are in "up" state
+            if (!nic.isLoopback() && nic.supportsMulticast() && nic.isUp())
                 nics.add(nic);
         }
         if (nics.size() <= 1) {
             System.out.println("Need 2 or more network interfaces to run. Bye.");
             return;

@@ -170,11 +170,11 @@
             for (;;) {
                 mcastsock.send(packet1);
                 mcastsock.send(packet2);
                 mcastsock.send(packet3);
 
-                Thread.currentThread().sleep(1000);   // sleep 1 second
+                Thread.sleep(1000);   // sleep 1 second
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }