equal
deleted
inserted
replaced
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 4686717 |
26 * @bug 4686717 |
27 * @summary Test MulticastSocket.setLoopbackMode |
27 * @summary Test MulticastSocket.setLoopbackMode |
|
28 * @library /lib/testlibrary |
|
29 * @build jdk.testlibrary.NetworkConfiguration |
|
30 * @run main/othervm SetLoopbackMode |
28 */ |
31 */ |
29 import java.net.*; |
32 import java.net.*; |
30 import java.io.IOException; |
33 import java.io.IOException; |
|
34 import java.util.Enumeration; |
|
35 import jdk.testlibrary.NetworkConfiguration; |
31 |
36 |
32 public class SetLoopbackMode { |
37 public class SetLoopbackMode { |
33 |
38 |
34 static final boolean FAILED = true; |
39 static final boolean FAILED = true; |
35 static final boolean PASSED = false; |
40 static final boolean PASSED = false; |
83 } |
88 } |
84 |
89 |
85 return PASSED; |
90 return PASSED; |
86 } |
91 } |
87 |
92 |
|
93 private static boolean canUseIPv6(NetworkConfiguration nc) { |
|
94 return nc.ip6MulticastInterfaces().toArray().length > 0; |
|
95 } |
|
96 |
88 public static void main (String args[]) throws Exception { |
97 public static void main (String args[]) throws Exception { |
89 int failures = 0; |
98 int failures = 0; |
|
99 NetworkConfiguration nc = NetworkConfiguration.probe(); |
90 |
100 |
91 MulticastSocket mc = new MulticastSocket(); |
101 MulticastSocket mc = new MulticastSocket(); |
92 InetAddress grp = InetAddress.getByName("224.80.80.80"); |
102 InetAddress grp = InetAddress.getByName("224.80.80.80"); |
93 |
103 |
94 |
104 |
95 /* |
105 /* |
96 * If IPv6 is available then use IPv6 multicast group - needed |
106 * If IPv6 is available then use IPv6 multicast group - needed |
97 * to workaround Linux IPv6 bug whereby !IPV6_MULTICAST_LOOP |
107 * to workaround Linux IPv6 bug whereby !IPV6_MULTICAST_LOOP |
98 * doesn't prevent loopback of IPv4 multicast packets. |
108 * doesn't prevent loopback of IPv4 multicast packets. |
99 */ |
109 */ |
100 InetAddress lb = InetAddress.getByName("::1"); |
110 |
101 if (NetworkInterface.getByInetAddress(lb) != null) { |
111 if (canUseIPv6(nc)) { |
102 grp = InetAddress.getByName("ff01::1"); |
112 grp = InetAddress.getByName("ff01::1"); |
103 } |
113 } |
104 |
114 |
|
115 //mc.setNetworkInterface(NetworkInterface.getByInetAddress(lb)); |
105 System.out.println("\nTest will use multicast group: " + grp); |
116 System.out.println("\nTest will use multicast group: " + grp); |
106 mc.joinGroup(grp); |
117 mc.joinGroup(grp); |
107 |
118 |
108 System.out.println("\n******************\n"); |
119 System.out.println("\n******************\n"); |
109 |
120 |