In this assignment you will create a networked date/time server and a client to access the server. You will need to write two complete sets of applications, the first will use the TCP protocol and the second will use UDP.
The basic interaction between the client and server should be as follows:
• Server listens for incoming client requests.
• Client connects (only for TCP) to server and sends ASCII request “What is the current date and time?”
• Server responds with the current date and time in the format “Current Date and Time – 09/29/2019 09:00:01”
• Client closes connection (only for TCP), server stays running listening for next connection
• Only required to handle one client interaction at a time
• Can listen on any port you choose
• Must respond to invalid requests with an error message
• Valid request is “What is the current date and time?”
• Response to valid request must be in the format:
“Current Date and Time – MM/DD/YYYY hh:mm:ss”
• Allows user to enter text commands to be sent to the server
• Displays response back from server
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.import socket
from datetime import datetime
# create udp socket
my_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
UDP_IP = '127.0.0.1'
UDP_PORT = 5005
# set up address and bind socket to it
server_address = (UDP_IP, UDP_PORT)
valid_request = 'What is the current date and time?'
invalid_response = 'The valid message should be: \n\t' + valid_request
# there isn't connection in UDP so
# the server doesn't have to listen and accept connection
data, addr = my_sock.recvfrom(1024)
str = data.decode()
print("Connection from ", addr)
response = invalid_response
if str == valid_...
By purchasing this solution you'll be able to access the following files: