Question: Problem 3 Problem 3: Socket Programming 1) Rewrite the Python code below using UDP socket programming rather than TCP socket (25 points) programming a. This
Problem 3

Problem 3: Socket Programming 1) Rewrite the Python code below using UDP socket programming rather than TCP socket (25 points) programming a. This means we are pretending that someone has written a web browser that will also use UDP-you assume this exists and do not worry about it at all. If you do not remember the exact method (function) or parameter names for UDP, feel free to make up your own names, and be sure to explain, in a comment, what you expect the method to do b. 2) Add programming comments so that any reader of your rewritten program, especially those who have not ever done socket programming (but have had CSC 111, so do know Python basics), will understand each line, or group of lines, of the program # CSC 249 WebSocket.py from socket import* serversocket = socket (AF INET, SOCK STREAM) serverHost ' localhost ' recvBuffer 1024 ServerPort = 1602 serverSocket.bind( (serverHost, serverPort)) serverSocket.listen (1) while True: connectionSocket, addr- serverSocket.accept () message - connectionSocket.recv (recvBuffer) filename = message. split ( ) [ 1 ] [ 1 : ] if path.exists(filename): fopn - open(filename) filedata = fopn.read ( ) connectionSocket.send ( "HTTP/1.1 200 OK ") for i in range (0, len (filedata)): connectionSocket.send(filedata[i]) connectionSocket.send(" " ) connectionSocket.close() else: connectionSocket.send( "HTTP/1.1 404 Not Found ") connectionSocket.send("
404 Not Found
") connectionSocket.close() serverSocket.close ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
