This exercise converts the above files into a simple email server and email client respectively. The server

Question:

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 consecutively in each of two further command windows. For the first client, log in with one of the names specified below (i.e., ‘Dave’ or ‘Karen’) and send a few emails (fewer than 10) to the other user. Then quit and run the client program again, this time logging in as the other user and selecting reading of his/her emails. The full 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 then the word ‘quit’.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: