Please take the following python server source code and add commenting and good programming practice updates:
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.decode().upper()
serverSocket.sendto(modifiedMessage.encode(), clientAddress)
Comments in python starts with "#" character. The entire line is considered to the a comment.
Note : We should always give an indentation after if, while and for loops. Since, you didn't mention any, I'm assuming all the statements written after while statement are part of while loop.
# Importing the required libraries i.e., socket
from socket import *
# Reserving an open port 12000 to serverPort so that it accepts
the incoming request
serverPort = 12000
# Creating an instance of Socket and assigned two variables to it, AF_INET and SOCK_DGRM
# AF_INET represents address of IPV4 family
#SOCK_DGRM corresponds to connection oriented protocol
serverSocket = socket(AF_INET, SOCK_DGRAM)
# Binding the port
# passing an empty string instead of the IP
# Enables our computer to listen to any incoming requests from
other computers on network
serverSocket.bind((’’, serverPort))
# Print statement to let user know that our socket is
ready
print(”The server is ready to receive”)
# This is an infinite loop which runs till it is interrupted or
an error occurs
while True:
# Configuring our computer to receive from Client address
2048
message, clientAddress = serverSocket.recvfrom(2048)
#Decoding the received message and coverting it into upper case
# Decoded message is stored in variable modifiedMessage
modifiedMessage = message.decode().upper()
# This modified message is now transferred to clientaddress
serverSocket.sendto(modifiedMessage.encode(), clientAddress)
Please take the following python server source code and add commenting and good programming practice updates:...