I create a socket and bind it to a unicast address. However, it reads packets sent to the broadcast address and I do not understand why.
IPAddress.TryParse("X.X.X.99", out ip);
Socket receiver = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
receiver.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
receiver.Bind(new IPEndPoint(ip, 9999));
byte rcvBuffer = new byte;
int bytesRead = receiver.Receive(rcvBuffer);
With this code I receive packets addressed to both "x.x.x.255:9999" and "x.x.x.99:9999" and do not understand why. Anyone know why?
Edited 7-Jun-12 12:15pm
This is broadcast, not multicast. the x.x.x.255 is a broadcast address.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)