CONFIG_NET_IPIP=y 默认Red Hat / Fedora/ Cent OS内核都支持multicast。
配置多播路由
命令route -n 可以查看配置的路由信息。
1 2 3 4 5 6 7
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.204.0 0.0.0.0 255.255.252.0 U 1 0 0 eth0 224.0.0.0 0.0.0.0 224.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.204.1 0.0.0.0 UG 0 0 0 eth0
或者/sbin/ip route show
1 2 3 4
# /sbin/ip route show 192.168.204.0/22 dev eth0 proto kernel scope link src 192.168.204.49 metric 1 224.0.0.0/3 dev lo scope link default via 192.168.204.1 dev eth0 proto stati
Channelsc= sb.bind().sync().channel(); if (sc instanceof OioDatagramChannel) { // skip the test for OIO, as it fails because of // No route to host which makes no sense. // Maybe a JDK bug ? sc.close().awaitUninterruptibly(); return; } DatagramChannelcc= (DatagramChannel) cb.bind().sync().channel();
// leave the group cc.leaveGroup(groupAddress, NetUtil.LOOPBACK_IF).sync();
// sleep a second to make sure we left the group Thread.sleep(1000);
// we should not receive a message anymore as we left the group before sc.writeAndFlush(newDatagramPacket(Unpooled.copyInt(1), groupAddress)).sync(); mhandler.await();