Store client requests for a server in a queue [Sockets]

0

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!

    
asked by Jose Antonio Cespedes Downing 15.09.2018 в 18:26
source

0 answers