how to block the accept method of socket when server is waiting for the connection from client? my code is here:
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4444, 100);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
}
Socket clientSocket = null;
try {
clientSocket = serv开发者_StackOverflow中文版erSocket.accept();
// Thread input = new InputThread(clientSocket.getInputStream());
} catch (IOException e) {
System.err.println("Accept failed.");
System.exit(1);
}
I want to block the accept method which is waiting for the client..
serverSocket.accept() itself is blocking and blocks until a connection is made.
精彩评论