Create a chat application consisting of a chat client

Assignment Help Python Programming
Reference no: EM132182323

Project - Chatroom

Project Goal

Create a Chat application consisting of a chat client and a chat server. The client and server must be written in Python and must use sockets.

Introduction

The chat application allows multiple chat clients to connect to a chat server. Connected clients can:

  1. list the members already logged in,
  2. log in with a username,
  3. exchange messages with other logged in users,
  4. log out.

The server has to accept and maintain connections to all the clients and relay chat messages between them.

Chat Client Overview

The chat client application has to do the following tasks:

1. Connect to a chat server. The client obtains the server IP address and the port it is listening on. Then, the client immediately attempts to connect to the server socket using TCP.
2. Accept commands from the user. The client must be able to handle the following commands. Parameters are enclosed in <>:

  • login <username>
  • list
  • sendto <username> <message>
  • logout
  • exit

Each line must begin with a command. The parameters (if any) are separated by a space. The commands and parameters are described in more detail below. In order to implement these commands correctly, the client will have to send and receive the following messages to/from the server:

a. Send messages to the server. The client must be able to send the following messages to the server.

  • login message
  • list message
  • sendto message
  • logout message

b. Accept incoming messages from the server. The client must be able to properly react to the following messages.

  • LIST message
  • RESPONSE message
  • SENDTO message

Commands from client to server

We now present the commands that a client must handle. Note: whenever a client prints an error message, it should not perform any other action.

login: sends a login message to register with the server using the provided username.
Parameter(s): a string to be used as the username.
Rules:
The string may not contain any white space. Screen names are treated as case sensitive.
Any extra parameters after the username must cause the client to print an error. The error must also be printed if the username is more than 20 characters in length or if the username is not present. The following is the error:
Bad username
Examples:
The following is an example of a valid command:
login John
The following is an example of an invalid command:
login John Doe

list: sends a list message requesting the list of users already logged in.
Parameter(s): none
Rules:
Any extra parameters must cause the client to print the following error:
Invalid command
Examples:
The following is an example of a valid command:
list
The following is an example of an invalid command:
list bob

sendto: sends a sendto message to the server to communicate with another client.
Parameters: The user name of the destination client and the text to send.
Rules:
If either or both of the parameters are missing or if the username contains more than 20 characters, the following error message should be printed to the console:
Bad username
If there are more than 65535 characters of text, the following error message should be printed to the console:
Bad message
Examples:
The following is an example of a valid command:
sendto John Hello, how are you?
The following is an example of an invalid command:
sendto JohnHello

logout: sends a logout message to the server.
Parameters: none.
Rules:
Any extra parameters must cause the client to print the error:
Invalid command
The client should not close the connection with the server when executing this command. After executing this command, the client should still be able to execute the list and login commands.
Examples:
The following is an example of a valid command:
logout
The following is an example of an invalid command:
logout Joe

exit: closes the client socket and exits the program.
Parameters: Takes no parameters
Rules:
Any extra parameters must cause the client to print the error:
Invalid command
Examples:
The following is an example of a valid command:
exit
The following is an example of an invalid command
exit client

Protocol Overview: For each message that the client sends to the server the server will send a message back. For a successful list message the server will return a LIST message back. For all other messages or an unsuccessful list Message, the server will respond with a RESPONSE Message. The client never sends messages back in response to messages received from the server.

Messages Sent from Server to Client

The following is the structure for messages the client receives from the server.

LIST message: sent in response to successful list messages received from the client.

RESPONSE message: sent in response to all messages received from the client, except where list messages are appropriate.
If the server finds that a list message from the client has a problem (i.e. the server cannot provide the list of logged in users), it will send a response message, NOT a list message.
If result is ok, the client must print the following message:
Success
If result is failure, the client must print the following message:
Failure
If the result is malformed packet, there is something wrong with your code.

SENDTO message: sent whenever another client wishes to communicate with us.
Client should be able to receive this message whenever it is logged in.
Whenever this message is received, the client application has to print the message in the form "<username>: <text message>" to the console. For example if Bob sends "Hi how are you?" to John, then John's client should print out: Bob: Hi How are you?

Attachment:- Project Chatroom.zip

Verified Expert

Two python programs were created for the multi-server client chatting program. The name of the programs is server and client.Both these programs contain the unique port number for connecting the client and server.The different menu was implemented inside the program for the operations like the list, send, quit etc.python 3 consoles used as server side, command prompt was used for client side.

Reference no: EM132182323

Questions Cloud

Shape an individual political opinion : Name and explain how a major factor can shape an individual's political opinion?
List four multinational companies that have invested : MGT101: Using the case as well as your own knowledge, explain three reasons for these manufacturers setting up factories in South Africa.
Strong federalists arguments : Who is considered the philosophical author of the US Constitution, known also for his strong federalists arguments?
Calculate the amount in the account : A savings account was set up where payments of $150 were made each month starting on May 20, 2010. Calculate the amount in the account
Create a chat application consisting of a chat client : CS3560 Project – Chatroom - Create a Chat application consisting of a chat client and a chat server. The client and server must be written in Python and must
Machiavelli use of power : How would you ascribe Machiavelli's use of power (positive or negative)?
What are some contributions that can be added : What are some contributions that can be added to the EACH Woman Act of 2017 that make this bill even better?
What would health care systems be able to do in real time : Envision what the health care system of 2030 might look like? Describe at least two technological advancements that would be available to patients.
Estimate Nike cost of capital : You are provided with a Harvard Case UVA-F-1353: Nike's Cost of Capital. Using the method followed by Joanna Cohen, estimate Nike's cost of capital

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd