Question: Python Make a simple application that connects to a server, expects to receive accio sequence from the server, sends the following confirm-accio Then expects to

Python

Make a simple application that connects to a server, expects to receive accio sequence from the server, sends the following

confirm-accio 

Then expects to receive accio again, sends the following

confirm-accio-again 

The client application MUST be implemented in client.py file, accepting three command-line arguments:

$ python3 client.py    

: hostname or IP address of the server to connect

: port number of the server to connect

: name of the file to transfer to the server after the connection is established.

Write a basic skeleton for client.py:

Add command-line parameter processing by looking at sys.argv.

Extend client.py to have routines to connect to the server/port specified as the command line parameter.

Test it with, for example, python3 client.py www.google.com 80 file.txt

Add routines to receive the command from the server. Note that the server does not to have to send this command in a single TCP data segment. In other words, .recv call may return a single byte. Your routine must be prepared to receive the command in small parts (e.g., character by character, including and .

Test it with a demo server.

Add routines to read file in chunks (e.g., 10000 bytes long) and send it over the socket.

Test again with the demo server, check if successful.

Add exception handling to gracefully handle disconnections.

Test using the second broken demo server

Add socket option and extend exception handling for 10 second timeout.

To test connection timeout, try to connect to a wrong port on a remote server. Do not try localhost, as you will immediately get an ICMP error and will not be able to test the timeout function.

To test 10 second disconnection handling, use the broken demo server.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!