Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment the server waits for clients to connect, accepts a connection, sends the accio command, afterwards receives confirmation, sends the accio command again,

In this assignment the server waits for clients to connect, accepts a connection, sends the accio command, afterwards receives confirmation, sends the accio command again, receives the second confirmation, and then receives binary file that client sends, counts the number of bytes received, and prints it out as a single number (number of bytes received not including the header size). Below i have provided the server and client files. Can someone explain why maybe i am failing these failed test cases(This is specefically for the server code)?

Failed Tests

9. Server aborts connection and prints ERROR when it does not receive data from client for more than 10 seconds (0.0/5.0)

10. Server accepts another connection after the first connection timed out (0.0/5.0)

11. Server successfully receives a small amount of data (~500 bytes) using the client (0.0/10.0)

12. Server prints the correct value for the received data from the previous test (0.0/10.0)

13. Server successfully receives a large amount of data (~10 MiBytes) using the client (without emulated delays and/or transmission errors) (0.0/10.0)

14. Server prints the correct value for the received data from the previous test (0.0/10.0)

15. Server successfully receives a large amount of data (~10 MiBytes) using the client (with emulated delays and/or transmission errors) (0.0/5.0)

16. Server prints the correct value for the received data from the previous test (0.0/5.0)

Client.py image text in transcribed Server.py image text in transcribedimage text in transcribed

mport sys mport socket command line argument python 3 server-s. py ry: port = int(sys.argv[1]) xcept (ValueError, IndexError): sys. stderr.write("ERROR: Incorrect port number ) sys. exit(1) ost =0.0.0.0 Create Socket : Socket() ith socket.socket(socket.AF_INET, socket._SOCK_STREAM) as sock: try: \# Bind socket to specific address and port: bind() sock.bind((host, port)) except 0verflowError: sys. stderr.write("ERROR: Port number must be 065535 ) sys. exit(1) \# listen for Socket : listen() sock. listen(10) while True: print('waiting for a connection...') try: #accept() clientSocket, clientAddress = sock. accept ( ) \# set timeout to 10 seconds clientSocket. settimeout (10) except socket.timeout: sys.stderr.write("ERROR: Connection timed out ) clientSocket. close() continue except: sys.stderr.write("ERROR: Failed to accept connection ") clientSocket. close() continue print('Accepted connection from ', clientAddress) \# send accio command clientSocket. send (b'accio ) print('sent') \# receive confirmation from client \# keep reading until full header message is received msg = clientSocket. recv(1024) print("Received: '\%s'" %msg ) \# \# send accio command again if msg==b confirm-accio : clientSocket, send (b'accio ) print("sent") msg=b \# receive second confirmation from client while b not in msg: info = clientSocket. recv(1) msg += info print("Received: %S%msg ) \# receive binary file client sends

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

=+ 4. Why should policymakers think about incentives?

Answered: 1 week ago

Question

=+ 2. What is the opportunity cost of seeing a movie?

Answered: 1 week ago