I am attempting to broadcast on my subnet broadcast address 100.100.255.255 rather than 255.255.255.255. Below is my test code. If I use 255.255.255.255 I see it just fine, but if I use 100.100.255.255 I get an ARP request “who has 100.100.255.255? Tell 100.100.1.5”. Am I doing something wrong in my code or is this an issue with the new 4.2 network stack?
Looks like my issue might be related to this
http://www.tinyclr.com/forum/topic?id=10532
public class Program
{
public static void Main()
{
//Uncomment just one
//string broadcastIP = "255.255.255.255";
string broadcastIP = "100.100.255.255";
// Start Ethernet (EMX)
EthernetBuiltIn Ethernet = new EthernetBuiltIn();
Ethernet.Open();
NetworkInterfaceExtension.AssignNetworkingStackTo(Ethernet);
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
networkInterfaces[0].PhysicalAddress = new byte[] { 0x00, 0x1A, 0xF1, 0x00, 0x42, 0x0D };
networkInterfaces[0].EnableStaticIP("100.100.1.5", "255.255.0.0", "100.100.0.1");
// Set up UDP endpoint
EndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("100.100.1.5"), 28598);
EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(broadcastIP), 28599);
Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
serverSocket.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.Broadcast, true);
serverSocket.Bind(localEndPoint);
byte[] sendData = new byte[] { 0x1E, 0x10, 0xFF, 0xFF };
for (; ; )
{
serverSocket.SendTo(sendData, remoteEndPoint);
Thread.Sleep(1000);
}
}
}