标签:远程开机
import java.io.IOException;
import java.net.*;
import java.util.*;
public class 远程开机 {
public static void main(String[] args) {
DatagramSocket ds = null; //建立套间字udpsocket服务
try {
ds = new DatagramSocket(9999); //实例化套间字,指定自己的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"); //需要发送的地址
} catch (UnknownHostException o) {
System.out.println("Cannot open findhost!");
System.exit(1);
}
DatagramPacket dp =
new DatagramPacket(buf, buf.length, destination , 9);
//打包到DatagramPacket类型中(DatagramSocket的send()方法接受此类,注意10000是接受地址的端口,不同于自己的端口!)
try {
ds.send(dp); //发送数据
} catch (IOException o) {
System.out.println(o.getMessage());
}
ds.close();
}
}
标签:远程开机
原文地址:http://11537662.blog.51cto.com/11527662/1965761