Question: Using UDP sockets, you will write a client and server program that enables the client to send a string of some specified length to the

Using UDP sockets, you will write a client and server program that enables the client to send a string of some specified length to the server over the network, and the server simply echoes back that string back to the client.(IN PYTHON)

The client program should take the following input parameters:

IP address of server

UDP port of server

Length of string to be sent

The client program will read in the above input parameters, initialize a string of the specified length[1], and send the message using the UDP socket API to the server running at the specified IP address and port. If the client does not receive a message back from the server within a certain amount of time (one second), the client should retry up to a maximum number of tries (3) before terminating.[2]The program output should print out trace information when data is sent and received, and account for error conditions. Client trace output must include:

A message when data is sent to the server indicating destination IP address and port and length plus content of the data sent

A message when data is received from the server indicating source IP address and port and contents of the data received

An error message when any error occurs such as when a time-out occurs because the server is not running

The server program should execute at a fixed port number, and be prepared to read in data up to a fixed maximum length (100 bytes)[3]. The server will wait in an infinite loop to receive data from a client, and then send the received data back to the client without modification. Server trace output must include:

A message when data is received from the client indicating source IP address and port and contents of the data received

Test Cases (both test cases must be demonstrated for full credit):

Test both client and server running on the same host, such as your computer (this should illustrate the client sending a single message and the server response)

Test client behavior when server is not running (this should illustrate the client sending 3 messages and timing out after each one)

Example of the client trace output (server responds):

Sending data to 127.0.0.1, 12000: XXXXXXXXXX (10 characters)

Receive data from 127.0.0.1, 12000: XXXXXXXXXX

Example of the client trace output (server does not respond):

Sending data to 127.0.0.1, 12000: XXXXXXXXXX (10 characters)

Message timed out

Sending data to 127.0.0.1, 12000: XXXXXXXXXX (10 characters)

Message timed out

Sending data to 127.0.0.1, 12000: XXXXXXXXXX (10 characters)

Message timed out

Example of server trace output:

The server is ready to receive on port: 12000

Receive data from client 127.0.0.1, 56777: XXXXXXXXXX

Sending data to client 127.0.0.1, 56777: XXXXXXXXXX

[1]The string may contain any value. Initializing it to a specified value will aid debugging.

[2]The socket API supports a timeout facility. See documentation on socket library relevant to programming language you are using.

[3]Input parameters may be read in to override these defaults, but this is not necessary.

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!