I'm using UdpClient
to send data on multicast address.
The code looks like this:
m_udpclientSender = new UdpClient();
m_remoteEndPoint = new IPEndPoint(m_multicastAddress, m_port);
m_udpclientSender.ExclusiveAddressUse = false;
m_udpclientSender.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
m_udpclientSender.JoinMulticastGroup(m_multicastAddress, 255);
m_udpclientSender.ExclusiveAddressUse = false;
m_udpclientSender.Send(buffer, buffer.Length, m_remoteEndPoint);
It is sent to the correct port/ip, but it issued from a random port(which is expected), but I need/want this to be sent from a specific port(the same port that I'm sending too).
I saw that: How to specify source port of a UdpPacket?
But I need to NOT exclusively use address, and if I give this in the constructor, I got an exception(saying that this is already bound).
I've to put the same port because the protocol defines that the response should not be multicasted.