Java server | is a subtopic of 3.5 - Technology Needed to Build Client-Server Systems |  |
is a kind of server |  |
may send messages to Java client at any time once a connection is established |  |
must have an instance of Socket class in order to exchange information with clients |  |
receives messages from the client using an instance of InputStream |  |
sends messages to the client using an instance of OutputStream |  |
sends stream of information to the client |  |
server | accepts connections from clients, normally involving some form of validation to ensure that the client is allowed to connect. |  |
can also be a client at the same time |  |
continues to serve currently connected clients after it has stopped listening |  |
disconnects clients - the client may request disconnection by sending a message to the server, the client may just disappear suddenly due to the client crashing or the network connecting going down, or the server may force a client to disconnect if the client is not behaving well |  |
does concurrently - Waiting for interactions with the user who is in charge of the server, and responding as necessary
- Waiting for clients to try to connect and establishing connections as needed
- For each connected client, waiting for messages coming from that client, and responding when messages arrive
|  |
keeps a record of the connection while a client is connected |  |
listens for clients attempting to connect |  |
may be accessed by many clients simultaneously |  |
may be located on the same computer as its clients or on a different computer |  |
must be able to handle connections from many clients |  |
must be able to respond to messages from all the connected clients |  |
must initialize itself so that it is able to provide the required service |  |
reacts to messages from connected clients: performing computations or obtaining information, and normally sending some information back to the requesting client and perhaps sending a message to another client or broadcasting messages to many clients at once. |  |
stops listening if the number of connected clients becomes too high, or prior to shutting down |  |
terminates when necessary, which involves such actions as notifying each client before terminating its connection |  |
usually operates with at least two concurrent threads, and in general n+2, threads where n is the number of connected clients |  |
will not accept new client connections if it has stopped listening |  |
program | is written by programmer |  |
should follow consistent guidelines that make the program easy to read |  |
process^2 | see also process |  |