Multicast with DatagramSocket

Hi Jules, now that you've been into the DatagramSocket stuff recently, could you guys have a look at supporting multicast ? (more info here


I had a quick look, but the suggested code that was posted back in 2012 is pretty divergent from the current files, and it's hard to see what the important changes are.. Would be happy to have a look if anyone can give me something more up-to-date to look at!

Hehe... that would've been my next question :) I'll try adapt the code to current codebase, and make a patch for it.

Well, I can now receive multicast packets, but for some reason, some packets are dropped. Those that start with "HTTP/1.1 200 OK..." are never(!) received.

Anyone that could shed light on what could cause this ?

I’ll take a look. It sounds like port sharing isn’t quite right.

Probably my bad, the UDP listener sees only the SSDP packets (, but the UPnP Device sniffer tool sees ALL messages, even the one that are unicast (i.e. the ones starting with "HTTP/1.1..."). So it might not be a problem at all.

Edit: UPnP tools can be found here.


Another problem is the way the DatagramSocket sets up the "to" address when sending packets. The source address is set to when sending the packets, which is a bit of a problem since the receiving multicast listener uses that source address to send UDP unicast back to the sender. However using this code , a message sent to the multicast group gets the correct source address, i.e.