Question: Aims Develop a networked application using TCP sockets Implement a protocol according to a given specification from both the client and server side Implement client
Aims
Develop a networked application using TCP sockets
Implement a protocol according to a given specification from both the client and server side
Implement clientside checking to ensure only valid messages are sent to the server
Introduction
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 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 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 loggedin 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 singleline 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 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 loggedin user, the server must respond with READ ERROR. Otherwise, the server must respond with followed by the response where is the sender of the earliest unread message for the loggedin 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 READ ERROR 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 loggedin 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.
Example
These examples show the protocol only. This is not how interactions with the program should look to the end user. Note, also, that the protocol does not include the "Client: or "Server: strings they are just included to make these examples clearer.
Example
Client: LOGIN my username contains the space character
Note that the server drops the connection after an error.
Example
Client: LOGIN bob
Server:
Client: COMPOSE alice
Client: Hi Alice!
Server: MESSAGE SENT
Client: READ
Server: READ ERROR
Client: COMPOSE alice
Client: I guess you're not online
Server: MESSAGE SENT
Client: COMPOSE bob
Client: At least you'll talk to me
Server: MESSAGE SENT
Client: READ
Server: bob
Server: At least you'll talk to me
Client: EXIT
Both client and server exit normally.
Example
Client: LOGIN alice
Server:
Client: COMPOSE alice
Client: Note to self: Read my messages
Server: MESSAGE FAILED
Client: READ
Server: bob
Server: Hi Alice!
Client: READ
Server: bob
Server: I guess you're not online
Client: EXIT
Both client and server exit normally.
Example
Client: LOGIN carol
Server:
Client: read
Note that the server drops the connection after an error.
Details:
required to support multiple consecutive clients in particular, this will require you to synchronise access to each user's message queue In either case, having a client disconnect should not cause the server to exit the server should instead wait for a new client to connect unless explicitly forced to exit.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
