我编写了一个应用程序,它接收发送方发送的多播数据包(包含音频).我使用过Netty 4并且已经在Windows上运行应用程序,但在Linux上运行时它不会收到多播数据包(Debian Wheezy(raspi)和Ubuntu 12).
我创建了一些可以发送和接收组播数据包的测试代码,结果如下:
发送Windows到Windows工作.
发送Linux到Windows的工作原理.
将Windows发送到Linux,发送但未收到数据包.
我以root身份运行应用程序并将SO_BROADCAST设置为true.
我错过了什么?
如果我使用标准的Java MulticastSocket而不是Netty,那么该应用程序可以运行,但我更喜欢使用Netty,因为它易于使用并简化了代码.
测试代码是:
public class TestMulticast {
private int port = 51972;
private Logger log = Logger.getLogger(this.getClass());
private InetAddress remoteInetAddr = null;
private InetSocketAddress remoteInetSocket = null;
private InetAddress localInetAddr = null;
private InetSocketAddress localInetSocket = null;
private DatagramChannel ch = null;
private EventLoopGroup group = new NioEventLoopGroup();
private boolean bSend = false;
public TestMulticast(String localAddress, String remoteAddress, String sPort, boolean bSend) {
this.bSend = bSend;
try {
localInetAddr = …Run Code Online (Sandbox Code Playgroud)