Question
In this project, you need to replicate the echo client and server program that we discussed in Chapter 2, and then you are required to
In this project, you need to replicate the echo client and server program that we discussed in Chapter 2, and then you are required to enhance the ECHO client/server program that we discussed in the class. (25%) A set of sample Python code for echo client/server using both TCP and UDP has been introduced in the class, please refer to the slides of Chapter 2. You need copy the code and test it on your computer. This will the foundation of next step. (45%) Choose either TCP or UDP version of the echo server/client, modify it to to accomplish the following function: Server side program should listen on port 9999 for incoming request. User(e.g. me) runs the client program to connect to server. Client program reads a sentence typed in by user via keyboard and user can select a command, then it sends both the command and the sentence to the server. Upon receipt of the sentence and command, server converts all the letters in the sentence into uppercase letters or lower letters or other format based on the received command, and sends the result back to the client. Client program displays the replied sentence on the screen. Your server should support at least three commands: all uppercase, all lowercase, and another commands that you designed(something like initial caps, reverse each word, reverse the entire sentense, etc.). Other programming languages are also allowed. (20%) You also need to provide a document describing your protocol, i.e., underlying transport layer service, port numbers, the order and format of message sent and received by client/server, action associated with each message, etc. The document should provide enough information for others to implement client and server program to interact with yours. (10%) You should also need to discuss the following issues: How TCP or UDP would affect your application? Why you pick TCP over UDP?(Or vice versa) Is your protocol stateful or stateless? How does the other type of design would affect your application? (Hint: this has nothing to do with whether you use TCP or UDP.) Is your server program able to communicate with multiple clients at the same time?
UDP Client:from socket import *
serverName = hostname
serverPort= 12000
clientSocket= socket(AF_INET,SOCK_DGRAM)
message = input(Input lowercase sentence:)
serverAddress =(serverName, serverPort)
clientSocket.sendto(message.encode(), serverAddress)
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)
print(modifiedMessage.decode())
clientSocket.close()
UDP server:
from socket import *
serverPort= 12000
serverSocket= socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('', serverPort))
print(The server is ready to receive)
while True:
message, clientAddress = serverSocket.recvfrom(2048)
modifiedMessage = message.upper()
serverSocket.sendto(modifiedMessage
TCP Client:
from socket import *
serverName = servername
serverPort= 12000
clientSocket= socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = input(Input lowercase sentence:)
clientSocket.send(sentence.encode())
modifiedSentence = clientSocket.recv(1024)
print(From Server:, modifiedSentence.decode())
clientSocket.close()
TCP Server:
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind((,serverPort))
serverSocket.listen(1)
print(The server is ready to receive)
while True:
connectionSocket, addr = serverSocket.accept() sentence = connectionSocket.recv(1024).decode()
capSentence = sentence.upper()
connectionSocket.send(capSentence .encode())
connectionSocket.close()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started