After spending better part of the night, I haven't been able to make it work. Here is what I'm doing:
AdvertiserSocket = new DatagramSocket();
AdvertiserSocket.MessageReceived += MessageToConnectReceivedFromParticipantAsync;
_timer = new Timer(async state => await SendMessageAsync(), null, 0, AdvertiserInterval);
private async Task SendMessageAsync()
Stream outStream = (await AdvertiserSocket.GetOutputStreamAsync(AdvertiserGroupHost, AdvertiserPort)).AsStreamForWrite();
using (var writer = new StreamWriter(outStream))
_listenerSocket = new DatagramSocket();
_listenerSocket.MessageReceived += AdvertisementMessageReceivedFromManagerAsync;
Figured it out with the help of MS guy. This seems to be a bug in
DatagramSocket class. You need to send at least one message on the multicast group before you start receiving multicast data from other advertisers. As a workaround, you can send an empty message before you start listening. More details and sample code can be found on this SO post (which is an absolutely simplified version of this question).
Additionally, it confirmed the following:
trueon the advertiser socket.
BindServiceNameAsync()if it is only doing multicasting.
184.108.40.206and any other address in the multicast range works for multicasting. 255.255.255.255 is not needed and shouldn't be used.
Hope this helps someone down the road.