Multicast to directly connected WIFI device

I have a WIFI device, that I am experimenting with. From my macbook I can make a direct connection to the device over wifi. After I have WIFI connection I should be able to communicate with the device over multicast. However, as soon as I try to send a datagram packet to the camera when I am connected I get some IOException:

java.io.IOException: Can't assign requested address 

I reviewed some networking settings and found out that Multicast is enabled for my laptop, also I added the multicast address that is used (239.255.255.250) to the routing table. (Read this somewhere) Still no luck...

Why do I get this exception from my application?

Here is the code I use to connect:

DatagramSocket socket = null;
DatagramPacket packet = null;
try {
    socket = new DatagramSocket();
    InetSocketAddress iAddress = new InetSocketAddress("239.255.255.250", 1900);
    packet = new DatagramPacket(sendData, sendData.length,iAddress);
    socket.send(packet);

I think it has something to do with my network / setup. When I reconnect to my wireless acces point, my app doesn't give this exception and I can see the package in my console:

MacBook-Pro-van-Roy:~ Roy$ sudo tcpdump -ni en1 host 239.255.255.250
Password:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on en1, link-type EN10MB (Ethernet), capture size 65535 bytes
19:54:18.688367 IP 192.168.1.34.57428 > 239.255.255.250.1900: UDP, length 129
19:54:18.789447 IP 192.168.1.34.57428 > 239.255.255.250.1900: UDP, length 129
19:54:18.890506 IP 192.168.1.34.57428 > 239.255.255.250.1900: UDP, length 129

Answers


InetSocketAddress is not a InetAddress (it's a SocketAddress). You probably want something like this:

InetAddress addr = InetAddress.getByName("239.255.255.250");
packet = new DatagramPacket(sendData, sendData.length, addr, 1900);
socket.send(packet);

Need Your Help

How to display correctly Treeview with QML Qt 5.5

qt treeview qml qt5.5

I'm trying to create a correct Treeview with Qml Qt 5.5.

Does restricting the frames/s of a game engine (via vertical sync or common throttling), inflict latencies also on audio and input subsystems?

game-engine

I was contemplating the fact that inflicting frame per second restrictions is not ideal in regards to latency and performance since a monitor still has a chance to show something sooner (assuming no