You are at a restaurant eating lunch with a friend. After the meal, your friend realizes they left their wallet at home. Your friend gives you a piece of silver….
o complete the coding for the client and then run the server program in one command window and the client program in each of two further command windows (so that there are two clients communicating with the server at the same time).
This exercise converts the above files into a simple email server and email
client respectively. The server conversion has been done for you and is
contained in file EmailServer.java, a printed version of which appears on the
following pages for ease of reference. Some of the code for the client has also
been provided for you and is held in file EmailClient.java, a printed version
of which is also provided. You are to complete the coding for the client and
then run the server program in one command window and the client program
in each of two further command windows (so that there are two clients
communicating with the server at the same time). The details of this
simplified client-server application are given below.
• The server recognises only two users, called 'Dave' and 'Karen'.
• Each of the above users has a message box on the server that can
accept a maximum of 10 messages.
• Each user may either send a one-line message to the other or read
his/her own messages.
• A count is kept of the number of messages in each mailbox. As
another message is received, the appropriate count is incremented (if
the maximum has not been reached). When messages are read, the
appropriate count is reduced to zero.
• When sending a message, the client sends three things: the user's
name, the word 'send' and the message itself.
• When requesting reading of mail, the client sends two things: the
user's name and the word 'read'.
• As each message is received by the server, it is added to the
appropriate mailbox (if there is room). If the mailbox is full, the
message is ignored.
• When a read request is received, the server first sends an integer
indicating the number of messages (possibly 0) that will be sent and
then transmits the messages themselves (after which it reduces the
appropriate message count to 0).
• Each user is to be allowed to 'send' and/or 'read' as many times as
he/she wishes, until he/she decides to quit.
• When the user selects the 'quit' option, the client sends two things: the
user's name and the word 'quit'.