final JButton button_2 = new JButton();
button_2.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
try {
byte[] b = ("openJSQ").getBytes();
DatagramPacket data = new DatagramPacket(b, b.length,
InetAddress.getByName(ip.getText()), Integer
.parseInt(port.getText()));
Process p = Runtime.getRuntime().exec(c);
InputStream in = p.getInputStream();
BufferedReader br = new BufferedReader(
new InputStreamReader(in));
String l = null;
String txt = "";
while ((l = br.readLine()) != null) {
txt += l + "\n";
}
in.close();
// 打开服务器 开始服务
public static void openServer() throws Exception {
// 开启服务器 准备监听 8889
socket = new DatagramSocket(8889);
while (true) {
// /准备数据包 准备一个空篮子 准备接受苹果
byte[] d = new byte[1024 * 100];
DatagramPacket data = new DatagramPacket(d, d.length);
socket.receive(data);// 这里就是实际的接收数据方法
new UDPServer(data).start();// 开始处理 开起线程进行处理
}
}
public static void main(String[] args) throws Exception {
openServer();