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

  Evaluate quality of the random number generator in python

This program is going to evaluate the quality of the random number generator in Python by simulating dice rolls and looking at the distributions of the values.

  Construction of the data dictionary

A first systematic step to a data science process, as we have learned from the lectures and practical sessions, is to construct a data dictionary for the dataset.

  How many times each word has occurred in the text file

The values in this dictionary should be a count of how many times each word has occurred in the text file. Second, add the word into a data structure that is keeping track of word information for the completion process.

  Application that will allow user to maintain collections

Build a menu-driven application that will allow a user to maintain their collections. For example, I might have a coin collection, or a record collection, or a collection of all my valuable items.

  Write a python program that will multiply the two array

Write a Python program that will multiply the array A with the array B (see below). (note, you need to determine if you will multiply (A x B) or (B x A)).

  The program should allow the student

The program should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed.

  Write a program that reads the name of a data file

Write a program that reads the name of a data file which contains student ids (such as c1234500) and their scores. The program will find and print the average score, the number of students processed.

  Recursion to write a python function

Use recursion to write a Python function depth(LL), where LL is a nested list of lists of lists etc. of numbers (i.e., oat and int) and strings. We want to return the depth of nesting, i.e., how often, maximally, there is a list in a list etc

  Write a python program that will ask the user for a string

Write a Python program that will ask the user for a string and then use the number of characters in the string to print out whether that value is odd or even.

  Output a brief description of the game of hangman

Output the appropriate number of dashes and spaces to represent the phrase. Dashes are placeholders for letters.

  Write a python program that will index a set of documents

You are going to write a python program that will index a set of documents and build a function to search through these documents using the index

  Develop a program to solve the anteater bed problem

Develop a program to solve the Anteater Bed and Breakfast problem. Develop this code in its own BandB.py file. Pay very close attention to the instructions, especially about developing the program in incremental stages

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