What is the difference between an iterative server and a concurrent server, and which one should I be using?
In brief, an iterative server handles clients one at a time, in series, while a concurrent server handles many clients at the same time, in parallel.
When a server invokes the accept() method of a ServerSocket object, the server thread blocks until a client connects to the server. The server must handle the client's request then go back to listening for further client connections. In an iterative server, the main server method handles each client request in its entirety before moving on to accept the next request. Iterative servers are good when the requests take a known, short period of time. For example, requesting the current day and time from a time-of-day server.
To overcome this limitation of iterative servers, a separate thread can be created to handle each client session, allowing the server to deal with multiple clients simultaneously. This is known as a concurrent server: the main server method launches a thread to handle each client request, so multiple clients can simultaneously interact with the server while the server continues to listen for additional clients.