I am very new to C# and using UDP protocol. I have a C# application, and I am trying to simply broadcast/multicast (whichever is better) a message to one or more devices on a LAN Network to get them to restart using the #RESTART ASCII Command. Here is my code:
I
Expand|Select|Wrap|Line Numbers
- PAddress GroupAddress = IPAddress.Broadcast;
- int GroupPort = 8001;
- IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);
- string str = "#RESTART";
- byte[] sendBytes = Encoding.ASCII.GetBytes(str);
- Thread.Sleep(1000);
- sender.Send(sendBytes, sendBytes.Length, groupEP);
Upon receiving the command, the device(s) should instantaneously restart without having to dsend anything back to the application. This code does compile/build correctly with Visual Studio .NET 2003, but it doesn't do anything...can someone out there help me?? Is converting the #RESTART command to ASCII characters the wrong route to take?
Once again, to recap:
I am trying to broadcast the restart message to all devices on my LAN network. Once they receive this message, they should all instantenously restart. Please help me fix my code.
Thanks!!