Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC450 - Computer Networks Assignment #2 - HTTP over TCP In this assignment, you are to implement client-server communication over TCP transport-layer protocol using HTTP

image text in transcribed

image text in transcribed

CSC450 - Computer Networks Assignment #2 - HTTP over TCP In this assignment, you are to implement client-server communication over TCP transport-layer protocol using HTTP application-layer protocol. You are to submit code for two programs: one for client side (e.g. TCP Client.py) and one for server side (e.g. TCPServer.py). Compressed folder containing two source files must be submitted on Moodle. Requirements for server-side code: 1. Accepts and parses the HTTP GET request. 2. Gets the requested object from the server's file system*. 3. Creates an HTTP response message consisting of the requested object preceded by an appropriate response status line. 4. Sends the HTTP response directly to the client. 5. Sends an HTTP "404 Not Found" response back to the client if the requested object is not present. Requirements for client-side code: 1. Connects to the server using a TCP connection. 2. Sends an HTTP GET request to the server. 3. Displays the server response as an output. 4. Takes command line arguments specifying the server IP address, the port at which the server is listening, and the name of the requested object. Sample command to run the client code: python TCP Client.py server_ip server_port filename Sample outputs of client code: at@at:~$ python TCPClient.py 192.168.1.12 12000 index.html HTTP request to server: GET /index.html HTTP/1.1 Host: 192.168.1.12 HTTP response from server: HTTP/1.1 200 OK

CSC 450: Computer Networks

Assignment #2

at@at:~$ python TCPClient.py 192.168.1.12 12000 home.html HTTP request to server: GET /home.html HTTP/1.1 Host: 192.168.1.12 HTTP response from server: HTTP/1.1 404 Not Found Sample output of server code: at@at:~$ python TCPServer.py The server is ready to receive... HTTP request: GET /index.html HTTP/1.1 Host: 192.168.1.14 Object to be fetched: index.html Object content:

CSC 450: Computer Networks

Assignment #2

HTTP response message: HTTP/1.1 200 OK

CSC 450: Computer Networks

Assignment #2

HTTP request: GET /home.html HTTP/1.1 Host: 192.168.1.12 Object to be fetched: home.html HTTP response message: HTTP/1.1 404 Not Found *Put an HTML file (e.g. index.html) in the same directory with the server code. When the server code is running, you should be able to access the index.html file (in browser) through server_ip:server_port/filename (e.g. 192.169.25.33:11000/index.html). Gets the requested object from the server's file system means opening and reading index.html file in server code (e.g. f = open(filename) ... f.read(), where filename is "index.html"). 2/2 CSC450 - Computer Networks Assignment #2 - HTTP over TCP In this assignment, you are to implement client-server communication over TCP transport-layer protocol using HTTP application-layer protocol. You are to submit code for two programs: one for client side (e.g. TCP Client.py) and one for server side (e.g. TCPServer.py). Compressed folder containing two source files must be submitted on Moodle. Requirements for server-side code: 1. Accepts and parses the HTTP GET request. 2. Gets the requested object from the server's file system*. 3. Creates an HTTP response message consisting of the requested object preceded by an appropriate response status line. 4. Sends the HTTP response directly to the client. 5. Sends an HTTP "404 Not Found" response back to the client if the requested object is not present. Requirements for client-side code: 1. Connects to the server using a TCP connection. 2. Sends an HTTP GET request to the server. 3. Displays the server response as an output. 4. Takes command line arguments specifying the server IP address, the port at which the server is listening, and the name of the requested object. Sample command to run the client code: python TCP Client.py server_ip server_port filename Sample outputs of client code: at@at:~$ python TCPClient.py 192.168.1.12 12000 index.html HTTP request to server: GET /index.html HTTP/1.1 Host: 192.168.1.12 HTTP response from server: HTTP/1.1 200 OK

CSC 450: Computer Networks

Assignment #2

at@at:~$ python TCPClient.py 192.168.1.12 12000 home.html HTTP request to server: GET /home.html HTTP/1.1 Host: 192.168.1.12 HTTP response from server: HTTP/1.1 404 Not Found Sample output of server code: at@at:~$ python TCPServer.py The server is ready to receive... HTTP request: GET /index.html HTTP/1.1 Host: 192.168.1.14 Object to be fetched: index.html Object content:

CSC 450: Computer Networks

Assignment #2

HTTP response message: HTTP/1.1 200 OK

CSC 450: Computer Networks

Assignment #2

HTTP request: GET /home.html HTTP/1.1 Host: 192.168.1.12 Object to be fetched: home.html HTTP response message: HTTP/1.1 404 Not Found *Put an HTML file (e.g. index.html) in the same directory with the server code. When the server code is running, you should be able to access the index.html file (in browser) through server_ip:server_port/filename (e.g. 192.169.25.33:11000/index.html). Gets the requested object from the server's file system means opening and reading index.html file in server code (e.g. f = open(filename) ... f.read(), where filename is "index.html"). 2/2

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions