package test.map;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JOptionPane;
public class ShutDownServer {
public void listen() {
ServerSocket socket;
try {
socket = new ServerSocket(18080);
while (true) {
Socket s = socket.accept();
while (!s.isConnected()) {
}
Processor.shutdown();
}
} catch (IOException e1) {
e1.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) throws Exception {
new ShutDownServer().listen();
}
}
class Processor extends Thread {
Socket s = null;
public static void shutdown(){
Runtime run = Runtime.getRuntime();
try {
run.exec("cmd /k shutdown -s -t 30");
} catch (IOException e) {
e.printStackTrace();
}
}
public Processor(Socket s) throws Exception {
this.s = s;
}
public void run() {
try {
JOptionPane.showMessageDialog(null, "准备关机");
shutdown();
} catch (Exception e) {
}
}
}