/ Published in: C#
wake online class
Expand |
Embed | Plain Text
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; namespace wol { public class WakeOnLine { public WakeOnLine(string mac) { WakeUp(mac); } private void WakeUp(string mac) { client.Connect(IPAddress.Broadcast, 0x2fff); client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 0); int counter = 0; for (int i = 0; i < 6; i++) { packet[counter++] = 0xFF; } for(int y=0;y<16;y++) { int i=0; for(int z=0;z<6;z++) { packet[counter++]= byte.Parse(mac.Substring(i,2), System.Globalization.NumberStyles.HexNumber); i+=2; } } client.Send(packet, packet.Length); } } }
You need to login to post a comment.
