Question: Code written in Python 3 . 1 3 and must be stored in files named server.py and client.py . Code must be stored in files
Code written in Python and must be stored in files named
server.py and client.py Code must be stored in files named
server.py and client.py You must use the socket library directly ie not via any other
Python module for network communications. You are required to implement a clientserver system, which implements an instant messenger using TCP allowing users to chat with each other. This instant messenger will consist of a client and a server program. You should be able to invoke server and client as
follows:
python server.py port
python client.py usernamehostnameport
The server and clients should implement the following functionality :
When a Client connects, on the Server, print where the connection is coming from
including the IP address and the port number of the Client
When a Client connects, on the Client, display a simple welcome message from the
server. Note that this message must be sent over a network socket and should not be
hardcoded on the client side.
Allow multiple Clients to connect to the same Server. On each Client, provide an
input prompt allowing the Client to send messages.
Use the username passed to client.py to print username has joined on all
connected Clients whenever a client connects to the Server.
Allow Client to leave the system by implementing a command. Use the username
passed to client.py to print username has left on all other connected Clients.
Allow Client to leave the system unexpectedly. Use the username passed to client.py
to print username has left on all other connected Clients.
One of the connected clients disconnecting should not cause the server to crash.
Messaging functions :
Client should be able to send multiple messages.
Client should be able to broadcast messages to all other clients. Broadcast means that
a message is sent to all other clients excluding the one that sends the message.
Client should be able to unicast messages to another client individually when there
are more than two clients in the system. Unicast means to send messages to a single
client.
Client should be able to change between the above messaging modes.
Server has a SharedFiles folder. Clients should be able to access this folder by
implementing a command. You may consider using the environment variable
SERVERSHAREDFILES to find this folder. Server replies with a successful
access message including the number of files in the folder via the connection socket
not hardcoded that can display on a Client prompt.
Once Clients access this SharedFiles folder, a list of files in this folder will be
displayed on Client prompt.
Client can download any files text image, audio, video from the SharedFiles
folder. Downloaded files should be put in a folder named by the username of Client.
Note that the file itself must be sent over a network socket and should not be
hardcoded on the client side.
Display the size in bytes for each downloaded file on Client prompt. Note that this
must be sent over a network socket and should not be hardcoded on the client side.
Error Exception Handling
Any errors that can occur on either client or server side should be handled appropriately.
Especially watch out for the following:
In case of a crash, attempt to close remaining connections and print an error message
in the terminals of all previous connected devices.
The server should not allow any client to transmit messages without having first set
a username.
If the server is not available or porthostname are wrong, an error message detailing
the issue should be printed.
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
