Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the first phase of this project, your will write a simple multi-threaded web server. A web server is a program that allows clients (typically

For the first phase of this project, your will write a simple multi-threaded web server. A web server is a program that allows clients (typically web browsers) to make network connections and download documents. A web browser will send requests for a document to your web server. When the web server receives a request, it fulfills the request by sending back the appropriate document on the same connection. Subsequent phases of this project will add functionality for servicing web application requests, but for now, your web server will simply a reply with the requested document that is stored on the servers disk. When executed, the web server should open the port passed as a command line argument to accept incoming TCP connections. When a new connection is accepted, your web server should create a new detached thread to handle the client connection. The new thread should:

Read a single HTTP request from the client connection. Parse the HTTP request to discover necessary information needed to retrieve the appropriate document (Note that we are only supporting GET requests for this assignment). if the request can be handled (the document exists) Read the page from the disk Construct a reply Send the reply to the client if the client is using HTTP 1.0 Close the client connection Otherwise (the client is using HTTP 1.0 with a Connection: Keep-Alive header or is using HTTP 1.1) loop to step 1 Otherwise the web server will return the appropriate error response to the client (and possibly close the connection - see step 3 above)

You do not have enough time during this course to create a fully compliant web server, but your web server should not crash on any input, no matter how badly formatted. To test your web server, you you can use Firefox, IE, Safari, or some other web browser. Make up some HTML pages and put them in your web servers directory (the directory where you start your web server). You must use C and or C++ for this assignment. For the second phase of this project, your web server will, when it sees that the document requested has a .lua or .luac extension, will not deliver the contents of the file, but will instead executed the corresponding Lua script in a Lua intrepreter. Your web server must parse the GET request URL to determine if any form values are passed, and construct a global table with the key value pairs that correspond to the form variables. Also, register a global function HTML_OUT with the Lua interpreter that, when called, sends output back to the server (makes a callback to the server's C/C++ function to deliver the results to the client through the socket).

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

Students also viewed these Databases questions

Question

Describe the seven standard parts of a letter.

Answered: 1 week ago

Question

Explain how to develop effective Internet-based messages.

Answered: 1 week ago

Question

Identify the advantages and disadvantages of written messages.

Answered: 1 week ago