//now use this class //MAC_ADDRESS should look like '013FA049' public void WakeFunction(string MAC_ADDRESS, string subNet) { //split subnet into AAA,BBB,CCC,DDD byte[] subNetBytes = new byte[4]; string[] splitSubNetString = subNet.Trim().Split('.'); for (int i = 0; i < 4; i++) { subNetBytes[i] = Convert.ToByte(splitSubNetString[i]); } IPAddress subnet = new IPAddress(subNetBytes); MAC_ADDRESS = MAC_ADDRESS.Replace("-", ""); WOLClass client = new WOLClass(); client.Connect(subnet, //new IPAddress(0xff1b3b95),//(0xffffffff), //255.255.255.255 i.e broadcast 0x2fff); // port=12287 let's use this one client.SetClientToBrodcastMode(); //set sending bites int counter = 0; //buffer to be send byte[] bytes = new byte[1024]; // more than enough :-) //first 6 bytes should be 0xFF for (int y = 0; y < 6; y++) { bytes[counter++] = 0xFF; } //now repeate MAC 16 times for (int y = 0; y < 16; y++) { int i = 0; for (int z = 0; z < 6; z++) { bytes[counter++] = byte.Parse(MAC_ADDRESS.Substring(i, 2), NumberStyles.HexNumber); i += 2; } } //now send wake up packet int returned_value = client.Send(bytes, 1024); }
internal static void wakeUpComputer(string MacAddress, string subNet) { WOLClass WOL = new WOLClass(); WOL.WakeFunction(MacAddress, subNet); }
internal static void wakeUpComputer(string MacAddress) { WOLClass WOL = new WOLClass(); WOL.WakeFunction(MacAddress, "255.255.255.255"); }