I currently have this method for a server:
private void listen() throws Exception{
try{
System.out.println("Server is listening on port " + getPort());
while (true) {
Socket socket = server.accept();
System.out.println("New client connected");
new ServerThread(socket).start();
}
} catch (IOException ex) {
System.out.println("Server exception: " + ex.getMessage());
ex.printStackTrace();
}
}
And what I would like is to be able to store in a queue the different connections made by the clients to the server (this in order that when there are at least two requests in the queue they can leave)
Any recommendation / suggestion is welcome. Thank you very much!