Java server | is a subtopic of 3.5 - Technology Needed to Build Client-Server Systems | ![2001-08-30 14:56:20.0](facet.gif) |
is a kind of server | ![2001-08-30 14:56:20.0](facet.gif) |
may send messages to Java client at any time once a connection is established | ![2001-08-30 14:56:20.0](facet.gif) |
must have an instance of Socket class in order to exchange information with clients | ![2001-08-30 14:56:20.0](facet.gif) |
receives messages from the client using an instance of InputStream | ![2001-08-30 14:56:20.0](facet.gif) |
sends messages to the client using an instance of OutputStream | ![2001-08-30 14:56:20.0](facet.gif) |
sends stream of information to the client | ![2001-08-30 14:56:20.0](facet.gif) |
server | accepts connections from clients, normally involving some form of validation to ensure that the client is allowed to connect. | ![2001-08-30 14:57:28.0](facet.gif) |
can also be a client at the same time | ![2001-08-30 14:57:28.0](facet.gif) |
continues to serve currently connected clients after it has stopped listening | ![2001-08-30 14:57:28.0](facet.gif) |
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 | ![2001-08-30 14:57:28.0](facet.gif) |
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
| ![2001-08-30 14:57:28.0](facet.gif) |
keeps a record of the connection while a client is connected | ![2001-08-30 14:57:29.0](facet.gif) |
listens for clients attempting to connect | ![2001-08-30 14:57:29.0](facet.gif) |
may be accessed by many clients simultaneously | ![2001-08-30 14:57:29.0](facet.gif) |
may be located on the same computer as its clients or on a different computer | ![2001-08-30 14:57:29.0](facet.gif) |
must be able to handle connections from many clients | ![2001-08-30 14:57:29.0](facet.gif) |
must be able to respond to messages from all the connected clients | ![2001-08-30 14:57:29.0](facet.gif) |
must initialize itself so that it is able to provide the required service | ![2001-08-30 14:57:29.0](facet.gif) |
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. | ![2001-08-30 14:57:29.0](facet.gif) |
stops listening if the number of connected clients becomes too high, or prior to shutting down | ![2001-08-30 14:57:29.0](facet.gif) |
terminates when necessary, which involves such actions as notifying each client before terminating its connection | ![2001-08-30 14:57:29.0](facet.gif) |
usually operates with at least two concurrent threads, and in general n+2, threads where n is the number of connected clients | ![2001-08-30 14:57:29.0](facet.gif) |
will not accept new client connections if it has stopped listening | ![2001-08-30 14:57:29.0](facet.gif) |
program | is written by programmer | ![2001-08-30 14:57:05.0](facet.gif) |
should follow consistent guidelines that make the program easy to read | ![2001-08-30 14:57:06.0](facet.gif) |
process^2 | see also process | ![2001-08-30 14:57:05.0](facet.gif) |