Multicast UDP socket

I would like to open a UDP socket that sends data to a multicast group and receives unicast messages.

My current configuration is to open a UDP socket with:

socket(4, Sn_MR_UDP, 2222, SF_BROAD_BLOCK);

and send the data with

sendto( 4, *message_buffer, message_length, multicastAddr, 2222);

The problem is that, although the multicast address is correct, the destination MAC address is the MAC address of the receiving device, not the multicast hardware address.

W5500 Broadcast Server - TCP/IP Chip / W5500 - WIZnet Developer Forum maybe this will help?

I don’t see the destination hardware address being configured in the code in the provided link. Also, I think my situation is slightly different than that post. They were trying to receive multicast/broadcast frames with the W5500; I am trying to send multicast frames and receive unicast frames with W5500

Does the destination hardware address automatically get updated when I pass the multicast IP address to the sendto() function?

Specifically, I am trying to send to multicast group; the destination hardware should be updated to multicast address but right now it is filled with the receiver’s MAC address

Look at the W6100 datasheet chapter 6.3.3, this may give some good idea.
It seems MC must not have ARP done, therefore try using SEND_MAC.

In chapter 6.3.3, it looks like I have to set the appropriate DHAR register myself.

In this multicast example provided by WIZnet, they never set DHAR, I am not sure how this works:

Also in the W5500 datasheet section 4.2, for multicasting in UDP mode, it says to set Sn_DIPR & Sn_DPORT, it does not say anything about Sn_DHAR.