QuestionQuestion

Overview
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
Detailed Requirements
Server
• 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”
Client
• Allows user to enter text commands to be sent to the server
• Displays response back from server

Solution PreviewSolution Preview

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
import sys
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)
my_sock.bind(server_address)

valid_request = 'What is the current date and time?'
invalid_response = 'The valid message should be: \n\t' + valid_request

while True:
    # 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:
Solution.zip.

$30.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats