I am developing a system that is sending UDP packets using LWIP on Nios processor. I have developed a C# application to allow visualization of the received data.
The issue that I am having is on receiving data on the C# application when sending to multicast addresses. On the com+uter running the C# app I am able to visualized the incoming packets addressed for IP 225.0.0.1(multicast address) but my C# app does not receive them.
The C# app receives data sent to a network address, for example 192.168.0.100 or when data is sent to 255.255.255.255 (in this case I can run the app in two diferrent computers and both receive the same data).
I have read several answers here on the forum and tried them all.
The code that I am using currently is:
UdpClient udpClientImage;
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 8884);
udpClientImage = new UdpClient(RemoteIpEndPoint);
udpClientImage.EnableBroadcast = true;
IPAddress m_GrpAddr;
m_GrpAddr = IPAddress.Parse("225.0.0.1");
udpClientImage.JoinMulticastGroup(m_GrpAddr);
while (true)
{
Byte[] receiveBytes = udpClientImage.Receive(ref RemoteIpEndPoint);
senderIPAddress = RemoteIpEndPoint.Address;
string returnData = Encoding.ASCII.GetString(receiveBytes);
}
Am I missing something in order to receive the multicast addresses?
Any help would be welcome,
Your UdpClient has to join the multicast group to listen. It's not automatic.
See MSDN for more information about this method.