none
Receiving UDP multicast message in C# application RRS feed

  • Question

  • Hi there,

    I'm actually struggling with a problem considering network multicasts in C#. To be honest I'm not that expert in multicasts. My problem is. I do have a device on the network who is sending multicast messages on a regular basis. I now wan't my C# application to be capable to receive those messages. However, I didn't get it manage. Here is a snippet of one of the multicast telegrams from the sending device:

    multicast telegram

    As you can see the messages are being sent to 224.168.100.2 - coming from address 169.254.2.0. I've tried several implementations in C# (and C++). I used approaches with UDPClient as well as with Socket. I also did a test run with the sample code given in here: https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.multicastoption?view=netframework-4.7.2 But, as mentioned, no luck so far. Of course I also shut down my firewall. Furthermore I tried several IGMPVersion settings within HKLM:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
    "IGMPVersion"=dword:00000003

    Nothing helped. I am able to send messages onto the multicast address. However reception isn't working for some reason. If I'm right then a sending application does not need to join a multicast group, right?

    One additional thing. I'm trying to receive the multicast messages on my secondary network interface card. That's why I used to bind my listening application to the network address of my secondary network interface card before the multicast membership is being pronounced.

    Any hints are welcome. Thanks in advance.

    Best regards,
    Peter

    Monday, November 5, 2018 1:53 PM

All replies

  • Is your secondary card on the same subnet?  Routers will not forward multicast messages outside of the originating subnet.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Tuesday, November 6, 2018 12:23 AM
  • Hi pkuebler,

    Does it throw any exception? if yes, please share the detailed error message. 

    In addition, the following document provide a complete sample about IP Multicasting in C# about for your reference.

    https://www.codeproject.com/Articles/1705/IP-Multicasting-in-C

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 6, 2018 6:26 AM
    Moderator
  • Thanks for that hint. I'll check this on the sending side. However, there is no router in between. It's a direct connection. And if I take a look on the traffic via Wireshark I can see the messages as well.
    Tuesday, November 6, 2018 3:17 PM
  • Hi Zhanglong,

    thanks for your support. It actually does not throw any exception. The receive statement simply does not return and waits and waits for answers. However it does not receive anything.

    Best regards,
    Peter

    Tuesday, November 6, 2018 3:21 PM
  • Hi pkuebler,

    Since I could reproduce the issue on my side, I am not sure what cause the issue, and you could check the document that I mentioned.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 7, 2018 2:46 AM
    Moderator