How to register a global hotkey for your application in C#

How to register a global hotkey for your application in C#

Register a hotkey for your application that can be triggered even if your form is minimized and does not have focus. More »

How to download a file in C# (progressbar and download speed)

How to download a file in C# (progressbar and download speed)

Learn how to download files in C# while displaying the percentage and the download speed. More »

UDP hole punching implementation in C#

UDP hole punching implementation in C#

Learn how to implement UDP hole punching so you can make your clients life a lot easier by not forcing them to open ports on their end. More »

 

Wake-on-Lan (WoL) in C#

Wake on LAN is a computer networking standard that allows devices to be powered on when they receive a specific network message, if your device supports this feature.

In this example we will demonstrate how to craft this “magic” packet in C#. The concept of the packet is fairly simple. The packet must contain anywhere in the payload six (6) 255 bytes in a row (FF in hexadecimal) followed by the MAC address of the device repeated sixteen times.

As an example, if your device MAC address is 01-00-00-00-00-02 the payload will look like this:

You can find the implementation of WoL in C# below:

And the result…
Wireshark WoL Result

Feel free to leave your questions or feedback in the comment section below.

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on LinkedInShare on RedditPin on PinterestShare on TumblrDigg thisPrint this pageEmail this to someone

4 Responses to Wake-on-Lan (WoL) in C#

  1. Jyotiranjan Khatua says:

    It is not working for me.

  2. John says:

    This is awesome, and works great. Thank you

  3. a says:

    You should note that this sends the WoL packet through the default network card, and not all cards if you have more than one.

  4. hussam says:

    that very naice thanks

Leave a Reply

Your email address will not be published. Required fields are marked *