In this assignment you will be creating a network messaging


In this assignment, you will be creating a network messaging system that allows users to leave messages for other users. Your task is to use TCP sockets to create a server process that can store messages and allow them to be retrieved, and a client process that can be used to interact with the server. The protocol that your solution must implement is described below.

Protocol

Each command and response in the protocol consists of a string of ASCII characters followed by the line feed character (ASCII code 10). All commands and responses are case sensitive.

An interaction begins when a client sends a LOGIN command to the server (where is replaced with the name of the user to log in). Usernames must not include space (ASCII code 32) characters. If a LOGIN command is sent with the username containing a space, the server should see this message as an error.

The server responds to a LOGIN command with the number of messages that are currently stored on the system for the user with the given username. Thus, if there are no messages for the user, the server will respond with θ.

After this response, the client can choose to either COMPOSE a message to be sent to a user, READ a message that was previously sent to the logged-in user, or EXIT the system.

To compose a message, the client sends a COMPOSE command (where is the name of the user they wish to send a message to), followed by a command (where is the single-line message to be sent), to the server. If the server successfully stores the message, the server must respond with MESSAGE SENT. Otherwise, the server must respond with MESSAGE FAILED. Your server must be able to store at least 100 unread messages for each user before failing (though it would be better if unlimited messages were supported).

To read a message, the client sends a READ command to the server. If there are no messages for the logged-in user, the server must respond with NO MESSAGES. Otherwise, the server must respond with , followed by the response (where is the sender of the earliest unread message for the logged-in user and is the content of that message). The message must then be removed from the server so that any further READ command would result in a different message being delivered to the user (or a NO MESSAGES response if there were no more messages).

To exit, the client sends an EXIT command and then disconnects from the server. When the server receives an EXIT command it must close the connection.

After a COMPOSE or READ interaction, the client can choose to either COMPOSE a message to be sent to a user, READ a message that was previously sent to the logged-in user, or EXIT the system.

Any other message sent to or from the client is considered an error, and should result in the receiving party dropping the connection.

Details -

1. startServer.sh which takes a port number as its only command-line parameter and attempts to start a server on that port. If the server is unable to be started (perhaps because that port is already in use), your program should exit with an appropriate error message.

2. startClient.sh which takes a host name as its first command-line parameter and a port number as its second command-line parameter and attempts to connect to the server with the given host name and port number. If the client is unable to connect, it should exit with an appropriate error message.

When your client first starts, it should ask for the user's username and automatically send a LOGIN message to the server. Your client should then guide the user through an interaction with the server until the user chooses to exit or the server responds with an invalid message (in which case you should indicate to the client that something has gone wrong with the server before exiting). It is important that your client ensures that only valid commands are sent to the server. If user input would result in an invalid command (e.g. the user includes a space character in their username), your client should notify the user of the problem and request new input.

Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
Computer Networking: In this assignment you will be creating a network messaging
Reference No:- TGS02263922

Expected delivery within 24 Hours