Import java.io.IOException;
Import java.net.*;
Import java.util.*;
public class remote Boot {
public static void Main (string[] args) {
Datagramsocket ds = null; Establishment of the suite word udpsocket service
try {
ds = new Datagramsocket (9999); Instantiate a suite word, specify your own port
} catch (SocketException e) {
SYSTEM.OUT.PRINTLN ("Cannot open port!");
System.exit (1);
}
byte a = integer.valueof (0xb8). Bytevalue ();
byte B = integer.valueof (0x97). Bytevalue ();
byte C = integer.valueof (0x5a). Bytevalue ();
byte d = integer.valueof (0x68). Bytevalue ();
byte E = integer.valueof (0x64). Bytevalue ();
byte F = integer.valueof (0x6f). Bytevalue ();
byte g = integer.valueof (0xFF). Bytevalue ();
Byte[] buf= {g,g,g,g,g,g,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b , c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f,a,b,c,d,e,f , a,b,c,d,e,f,a,b,c,d,e,f};
(0XB8) (0x97) (0x5a) (0x68) (0x64) (0x6f)
InetAddress destination = null;
try {
Destination = Inetaddress.getbyname ("255.255.255.255"); Address that needs to be sent
} catch (Unknownhostexception o) {
SYSTEM.OUT.PRINTLN ("Cannot open findhost!");
System.exit (1);
}
Datagrampacket DP =
New Datagrampacket (buf, Buf.length, Destination, 9);
Packaged into the Datagrampacket type (the Datagramsocket send () method accepts this class, note that 10000 is the port that accepts the address, unlike its own port! )
try {
Ds.send (DP); Send data
} catch (IOException o) {
System.out.println (O.getmessage ());
}
Ds.close ();
}
}
Remote boot. java