Question: Rewrite the TCPserver and the TCPclient code to allow the server display a message from the server indicating it accepted the TCPclient request for capitalization.

Rewrite the TCPserver and the TCPclient code to allow the server display a message from the server indicating it accepted the TCPclient request for capitalization.

TCPserver.py

from socket import * serverPort = 12455 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() capitalizedSentence = sentence.upper() connectionSocket.send(capitalizedSentence.encode()) connectionSocket.close()

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

UDPserver.py

from socket import * serverPort = 13000 serverSocket = socket(AF_INET, SOCK_DGRAM) serverSocket.bind(('', serverPort)) print ("the server is ready to receive") while 1: message, clientAddress = serverSocket.recvfrom(2048) modifiedMessage = message.decode() .upper() serverSocket.sendto(modifiedMessage.encode(), clientAddress)

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

TCPclient.py

from socket import * serverName = 'Use IP address of the server computer' serverPort = 13000 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()

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

UDPclient.py

from socket import * serverName = 'Use IP address of the server computer you are using' serverPort = 13000 clientSocket = socket(AF_INET, SOCK_DGRAM) message = input('Input lowercase sentence:') clientSocket.sendto(message.encode(), (serverName, serverPort)) modifiedMessage, serverAddress = clientSocket.recvfrom(2048) print (modifiedMessage.decode()) clientSocket.close()

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!