# Multicast with DatagramSocket

**URL:** <https://forum.juce.com/t/multicast-with-datagramsocket/14556>\
**Category:** General JUCE discussion\
**Created:** [March 31, 2015, 8:34am UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556 "2015-03-31T08:34:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robiwan](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/robiwan/32/2446_2.png) [@robiwan](https://forum.juce.com/u/robiwan)\
**Post date:** [March 31, 2015, 8:34am UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/1 "2015-03-31T08:34:54Z")

</div>

Hi Jules, now that you've been into the DatagramSocket stuff recently, could you guys have a look at supporting multicast ? (more info here&nbsp;http://www.juce.com/forum/topic/dataramsocket-intended-be-used-half-duplex)

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 31, 2015, 1:22pm UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/2 "2015-03-31T13:22:58Z")

</div>

I had a quick look, but the suggested&nbsp;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!

---

<div class="post-metadata">

**Author:** ![robiwan](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/robiwan/32/2446_2.png) [@robiwan](https://forum.juce.com/u/robiwan)\
**Post date:** [April 1, 2015, 6:52am UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/3 "2015-04-01T06:52:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robiwan](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/robiwan/32/2446_2.png) [@robiwan](https://forum.juce.com/u/robiwan)\
**Post date:** [April 8, 2015, 1:25pm UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/4 "2015-04-08T13:25:43Z")

</div>

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

Anyone that could shed light on what could cause this ?

---

<div class="post-metadata">

**Author:** ![jfitzpat](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jfitzpat](https://forum.juce.com/u/jfitzpat)\
**Post date:** [April 9, 2015, 1:31am UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/5 "2015-04-09T01:31:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robiwan](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/robiwan/32/2446_2.png) [@robiwan](https://forum.juce.com/u/robiwan)\
**Post date:** [April 9, 2015, 5:42am UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/6 "2015-04-09T05:42:00Z")

</div>

Probably my bad, the UDP listener sees only the SSDP packets (239.255.255.250:1900), but the UPnP&nbsp;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.&nbsp;https://software.intel.com/en-us/articles/intel-tools-for-upnp-technologies

&nbsp;

---

<div class="post-metadata">

**Author:** ![robiwan](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/robiwan/32/2446_2.png) [@robiwan](https://forum.juce.com/u/robiwan)\
**Post date:** [April 9, 2015, 8:29am UTC](https://forum.juce.com/t/multicast-with-datagramsocket/14556/7 "2015-04-09T08:29:32Z")

</div>

Another problem is the way the DatagramSocket sets up the "to" address when sending packets. The source address is set to 127.0.0.1 when sending the packets, which is a bit of a problem since the receiving multicast listener uses that&nbsp;source address to send UDP unicast back to the sender. However using this code&nbsp;http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/antony/example.html , a message sent to the multicast group gets the correct source address, i.e. 192.168.78.12..
