知道为什么在执行sendTCPBytes1到localhost之后没有执行这个system.exit(0)?
public static void killerButton() throws IOException {
String myCmd;
if (C.getOs().equals("Linux")) {
} else {
System.out.println("[bug]: forceclose");
sendTCPBytes1("forceclose", "localhost");
System.exit(0);
}
}
public static void sendTCPBytes1(String filmfr2, String localhost) throws IOException {
String downloaded = null;
Socket socket = new Socket(localhost, 58888);
DataOutputStream upload = new DataOutputStream(socket.getOutputStream());
BufferedReader download = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String c = filmfr2;
upload.writeBytes(c);
upload.flush();
String get;
downloaded = download.readLine();
System.out.println("[TCP]: FROM server: >>> " + downloaded);
socket.close();
}
答案 0 :(得分:1)
假设这实际上按我认为的方式工作,readLine()
是一个阻塞调用。如果您从未收到任何输入,它将无限期地等待。
答案 1 :(得分:1)
如果您的套接字连接失败,例如抛出IOException,不会调用System.exit(0)。