小编use*_*528的帖子

Netty 4在Linux上接收多播数据包

我编写了一个应用程序,它接收发送方发送的多播数据包(包含音频).我使用过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)

java linux netty raspberry-pi raspbian

5
推荐指数
0
解决办法
1694
查看次数

标签 统计

java ×1

linux ×1

netty ×1

raspberry-pi ×1

raspbian ×1