use of java.nio.channels.DatagramChannel 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();
}
use of java.nio.channels.DatagramChannel in project j2objc by google.
the class DatagramChannelMulticastTest method test_joinAnySource_nullNetworkInterface.
public void test_joinAnySource_nullNetworkInterface() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
try {
dc.join(GOOD_MULTICAST_IPv4, null);
fail();
} catch (NullPointerException expected) {
}
dc.close();
}
use of java.nio.channels.DatagramChannel in project j2objc by google.
the class DatagramChannelMulticastTest method test_joinSourceSpecific_mixedAddressTypes.
public void test_joinSourceSpecific_mixedAddressTypes() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
try {
dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface, UNICAST_IPv6_1);
fail();
} catch (IllegalArgumentException expected) {
}
try {
dc.join(GOOD_MULTICAST_IPv6, ipv6NetworkInterface, UNICAST_IPv4_1);
fail();
} catch (IllegalArgumentException expected) {
}
dc.close();
}
use of java.nio.channels.DatagramChannel in project j2objc by google.
the class DatagramChannelMulticastTest method test_joinAnySource_processLimit.
public void test_joinAnySource_processLimit() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
for (byte i = 1; i <= 25; i++) {
InetAddress groupAddress = Inet4Address.getByName("239.255.0." + i);
try {
dc.join(groupAddress, ipv4NetworkInterface);
} catch (SocketException e) {
// There is a limit, that's ok according to the RI docs. For this test a lower bound of 20
// is used, which appears to be the default linux limit.
// See /proc/sys/net/ipv4/igmp_max_memberships
assertTrue(i > 20);
break;
}
}
dc.close();
}
use of java.nio.channels.DatagramChannel in project j2objc by google.
the class DatagramChannelMulticastTest method test_block_null.
public void test_block_null() throws Exception {
if (!supportsMulticast) {
return;
}
DatagramChannel dc = createReceiverChannel();
MembershipKey membershipKey = dc.join(GOOD_MULTICAST_IPv4, ipv4NetworkInterface);
try {
membershipKey.block(null);
fail();
} catch (NullPointerException expected) {
}
dc.close();
}
Aggregations