Skip to content Skip to sidebar Skip to footer

Multicast - No Such Device

I am trying to connect to a multicast group using the following piece of code: int flag_on = 1; /* socket option flag */ struct sockaddr_in mc_addr; /* socket add

Solution 1:

I had a very similar problem, although I was using java interface. In my case, I was getting "No such device" error until I explicitly stated which interface should be handling multicast packets. In my case, that was an ethernet interface. Again this is not quiet your case, since you're using JNI, and also since you probably don't need eth0, but I hope it'll help:

Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
NetworkInterface eth0 = null;
while (enumeration.hasMoreElements() {
    eth0 = enumeration.nextElement()
    if (eth0.getName().equals("eth0")) {
        //there is probably a better way to find ethernet interfacebreak;
    }
}

InetAddress group = InetAddress.getByName(IP);
MulticastSocket s = new MulticastSocket(PORT);
s.setSoTimeout(10000);
//s.joinGroup(group); //this will throw "No such device" exception 
s.joinGroup(new InetSocketAddress(group, PORT), eth0); // this works just finefor (int i = 0; i < 10; ++i) {
    byte[] buf = newbyte[8096];
    DatagramPacket recv = new DatagramPacket(buf, buf.length);
    s.receive(recv);
    System.out.println("Recieved " + recv.getLength() + " bytes.");
}

s.leaveGroup(group);

So I guess the idea is that if you have more than 1 interface, you should explicitly specify which one are you using.

Solution 2:

you probably don't have a route for your multicast traffic. Try with:

route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0

Post a Comment for "Multicast - No Such Device"