我遇到了一个小问题(我不明白为什么,在其他应用程序中工作正常)与服务器 - 客户端对:
客户端
try (Socket socket = new Socket(host, 3307)) { // the host variable is written previously
try {
socket.getOutputStream().write(150);
socket.getOutputStream().flush();
}
catch (IOException ex) {
Logger.getLogger(PACSFunctions.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
服务器端:
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(3307);
Socket s = ss.accept(); //Accepts the connection without trouble;
final String num = "" + s.getInputStream().read(); //The debugger stop after here!
System.out.println(num); //Never executed, why?
} catch (IOException ex) {
Logger.getLogger(Imagea.class.getName()).log(Level.SEVERE, null, ex);
}
}