Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

At what level(s) was this OD intervention scoped?

Answered: 1 week ago