CS428/528 Project-1: Web Server

$30.00 $24.00

Part-1: Simple Web Server In this lab, you will learn the basics of socket programming for TCP connections in C++: how to create a socket, bind it to a specific address and port, as well as send and receive an HTTP packet. You will also learn some basics of HTTP header format. You will develop…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

Part-1: Simple Web Server

In this lab, you will learn the basics of socket programming for TCP connections in C++: how to create a socket, bind it to a specific address and port, as well as send and receive an HTTP packet. You will also learn some basics of HTTP header format.

You will develop a web server that handles one HTTP request at a time. For every HTTP request from the client, your web server should:

  • Set up a TCP connection.

  • Receive and parse the HTTP request.

  • Get the requested file from the server’s file system.

  • Create an HTTP response message containing the requested file preceded by header lines. If the requested file is not present in the server, the server should send an HTTP “404 Not Found” message back to the client.

  • Send the response directly to the client.

  • Close the TCP connection and wait for the next request.

The web browser on the client machine should successfully render the HTTP response message received from the server. Your web server should support transmitting HTML and PDF files.

CS428/528 Fall | Project-1: Web Server

Part-2: Running the Web Server Locally

Put the provided HTML file “home.html” in the same directory that the web server source file is in. Run the web server program from a terminal. The IP address of the localhost is “127.0.0.1”. Determine the port number you used for your web server (e.g., 28000). Now open a web browser and provide the corresponding URL. For example:

http://127.0.0.1:28000/home.html

home.html” is the name of the file you placed in the web server directory. Note also the use of the port number after the colon. You must replace this port number with whatever port you used in the web server code. We used the port number “28000” in the above example. The web browser should then display the contents of “home.html”. If you omit “:28000”, the web browser will assume port “80”, and you will get the web page from the web server only if your web server is listening at port “80”.

Try to get a file that is not present on the web server. You should get a “404 Not Found” message.

Part-3: Multi-threaded Web Server

In Part-1, the web server handles only one HTTP request at a time. Implement a multi-threaded web server that is capable of serving multiple requests simultaneously. Using threading, first, create a main thread in which your modified web server listens for clients at a fixed socket. When it receives a TCP connection request from a client, it will set up the TCP connection through another socket and service the client request in a separate thread. A separate TCP connection will be in a separate thread for each request/response pair.

You should implement a way to safely terminate the web servers’ main thread. To achieve this, you should ensure all TCP connections are closed and all threads are completed.

[BONUS] Part-4: Network Demonstration

In this part, you should demonstrate that your implementation of Part-3 works across two machines connected to the campus network. Machine one is expected to run the web server code, which waits for requests. Machine two (the client) is expected to use a web browser to request one or more files at the same time. The files should be fully transmitted to the client and correctly rendered in the client’s web browser without any issues.

CS428/528 Fall | Project-1: Web Server

Submission

  • Complete the “README.md”. You may write “n/a” where applicable (bugs, references, etc.).

  • Please submit the following files for Project-1 on Brightspace using the same file name and extension as here:

    • webserver1.cc (or .c/.cpp/.h/.hpp) for Part-1.

    • webserver2.cc (or .c/.cpp/.h/.hpp) for Part-3.

    • README.md

    • [Optional]: To submit a makefile for your project, append a “.txt” extension to the file and then submit.

  • You must submit your project before the deadline to be considered on time. Otherwise, it will be considered late even if your project was completely working before the deadline.

Please note that on Brightspace, we maintain all your submissions but only grade your most recent submission.

Testing

All submissions will be tested and graded under the Ubuntu 20.04 LTS operating system. To run a submission, we will follow the instructions provided by the group in the README.md file. We will test Part-3 of each submission thoroughly to:

  • Check the correctness of the implementation.

  • Check if the implementation supports HTML and PDF files.

  • Check the multi-threading is started correctly and terminated. We may use tools other than the web browser for such testing.

  • Check there is no compile time, run time, or memory leak errors using Valgrind.

Grading Rubric

Total: 100 points

  • Part 1: 25 points.

  • Part 3: 60 points

  • Submission: 15 points

    • README.md: 10 points

    • Naming Requirements: 5 points

  • Part-4: 10 points [BONUS]

  • If submission didn’t pass the plagiarism test(s): -100 points.

Department of Computer Science | Binghamton University | Page 4/4

CS428/528 Project-1: Web Server
$30.00 $24.00