I am sending directed broadcast packets from a UdpClient.
I am also listening on the target port on a second UdpClient (in the same app).
I do not want to see packets created by myself, so I thought it would just be a case of setting MulticastLoopback to false, but this does not work. I still see my own packets.
private readonly IPAddress BroadcastAddress = IPAddress.Parse("169.254.255.255");
private const int Port = 0x88a4;
private UdpClient _udpSend, _udpReceive;
private void InitUdp()
{
_udpSend = new UdpClient();
_udpSend.EnableBroadcast = true;
_udpSend.MulticastLoopback = false;
_udpSend.Connect(BroadcastAddress, Port);
_udpReceive = new UdpClient(new IPEndPoint(IPAddress.Any, Port));
_udpReceive.MulticastLoopback = false;
_udpReceive.BeginReceive(OnUdpPacket, null);
}
Any ideas anyone?
Am I able to achieve this with UdpClient or do I have to drop back to raw Sockets instead?
EDIT:
I've tried using a single UdpClient instance for both sending and recieving, but now I never receive any data, regardless of the MulticastLoopback setting!
I have tried listening on both IPAddress.Any, and my local IP, but I never see any packets.
private readonly IPAddress BroadcastAddress = IPAddress.Parse("169.254.255.255");
private const int Port = 0x88a4;
private UdpClient _udpClient;
private void InitUdp()
{
_udpClient= new UdpClient(new IPEndPoint(IPAddress.Any, Port));
_udpClient.Connect(BroadcastAddress, Port);
_udpClient.BeginReceive(OnUdpPacket, null);
}