The DatagramSocket class can also be used to send and receive multicast and broadcast packets. To showcase this functionality, we will start a listener and then send multicast/broadcast packets out on the network. We will direct these packets to the same 'Service Name' as the one that the listener is bound to, so they will get routed back to the listener and to any other elegible UDP sockets listening in the Local Area Network.
If the sample app fails to receive multicast or broadcast datagrams, please double-check that your Local Area Network equipment is configured to allow that type of traffic. A possible workaround is to run the sample app inside a Virtual Machine connected to an internal-only virtual network switch. Phone Emulator images are configured that way by default.