use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method test_block_cannotBlockWithSourceSpecificMembership.
public void test_block_cannotBlockWithSourceSpecificMembership() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface, UNICAST_IPv4_1);
try {
membershipKey.block(UNICAST_IPv4_2);
fail();
} catch (IllegalStateException expected) {
}
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method check_dropAnySource_twice.
private void check_dropAnySource_twice(InetAddress group, NetworkInterface networkInterface) throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(group, networkInterface);
assertTrue(membershipKey.isValid());
membershipKey.drop();
assertFalse(membershipKey.isValid());
// Try to leave a group we are no longer a member of - should do nothing.
membershipKey.drop();
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method test_joinAnySource_blockLimit.
public void test_joinAnySource_blockLimit() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey key = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface);
for (byte i = 1; i <= 15; i++) {
InetAddress sourceAddress = Inet4Address.getByName("10.0.0." + i);
try {
key.block(sourceAddress);
} catch (SocketException e) {
// There is a limit, that's ok according to the RI docs. For this test a lower bound of 10
// is used, which appears to be the default linux limit.
// See /proc/sys/net/ipv4/igmp_max_msf
assertTrue(i > 10);
break;
}
}
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method test_block_wildcardAddress.
public void test_block_wildcardAddress() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface);
try {
membershipKey.block(WILDCARD_IPv4);
fail();
} catch (IllegalArgumentException expected) {
}
dc.close();
}
use of java.nio.channels.MembershipKey in project j2objc by google.
the class DatagramChannelMulticastTest method checkMembershipKeyAccessors.
private void checkMembershipKeyAccessors(InetAddress group, NetworkInterface networkInterface) throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey key = dc.join(group, networkInterface);
assertSame(dc, key.channel());
assertSame(group, key.group());
assertTrue(key.isValid());
assertSame(networkInterface, key.networkInterface());
assertNull(key.sourceAddress());
dc.close();
}
Aggregations