---
title: "Multicast UDP socket"
url: "https://maker.wiznet.io/forum/15060"
markdown_url: "https://maker.wiznet.io/forum/15060/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Vien Huy Nguyen"
created: "2023-11-07T18:56:19+09:00"
last_activity: "2023-11-07T21:55:49+09:00"
language: "en"
views: 471
replies: 4
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Multicast UDP socket

## Question

Asked by Vien Huy Nguyen on 2023-11-07 in Ethernet Chips.

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.

## Replies

### Reply 1 by Eugeny, 2023-11-07

[W5500 Broadcast Server - TCP/IP Chip / W5500 - WIZnet Developer Forum](https://forum.wiznet.io/t/topic/4994) maybe this will help?

### Reply 2 by Vien Huy Nguyen, 2023-11-07 (in reply to reply 1)

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 239.192.8.32 multicast group; the destination hardware should be updated to multicast address but right now it is filled with the receiver’s MAC address

### Reply 3 by Eugeny, 2023-11-07

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.

### Reply 4 by Vien Huy Nguyen, 2023-11-07

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: <https://github.com/Wiznet/ioLibrary_Driver/blob/master/Application/multicast/multicast.c>

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.

---

Source: https://maker.wiznet.io/forum/15060
