I'm programming a wake on LAN program for our company. There are ca. 40-50 machines in our company and it should wake up every client. To wake up the clients I use this code:
private static void WakeUp(string macAddress)
{
WOLClass client = new WOLClass();
client.Connect(new IPAddress(0xffffffff), 0x2fff);
client.SetClientToBroadcastMode();
int counter = 0;
byte[] bytes = new byte[1024];
for (int e = 0; e < 6; e++)
{
bytes[counter++] = 0xFF;
}
for (int e = 0; e < 16; e++)
{
int i = 0;
for (int w = 0; w < 6; w++)
{
bytes[counter++] = byte.Parse(macAddress.Substring(i, 2), NumberStyles.HexNumber);
i += 2;
}
}
int returnedValue = client.Send(bytes, 1024);
}
public class WOLClass : UdpClient
{
public WOLClass()
: base()
{
}
public void SetClientToBroadcastMode()
{
if (this.Active)
{
this.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 0);
}
}
}
and on button_Click
event I just call the method WakeUp(macAddress)
Most clients wake up normally. But on some clients the computer just stops starting and stays in a black monitor with a little underline in the upper left corner. I already checked the macAddress for every client 3 times (ipconfig) and also in debug mode of VS2012. It's always identical and correct. So it cannot be a mac address issue.
Does someone know that problem?
Suggestions appreciated :)
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr. Stroustroupe.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.
The problem is not the code, it is the machine. Try debugging the hardware.
See, Wake on Lan is a magic packet. The network card gets it and then wakes up the machine.
That is all you do.
The machine then has to wake up properly, and something goes wrong there. There is nothing in your magic packet that can cause this - I would start with the usual suspects (biod versions coming to my mind).
If the machine can be confirmed to have started (and then stops during the start) then this is not a programming issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With