Reference no: EM13313759
Operating Systems and Concurrent Programming
Assignment 1
The purpose of this assignment is to write a multi-threaded web server. A start-up program, ass1.c, is available from the course web site. This is a socket server program that listens for requests on port 3490. You can use any other process, including a running instance of a browser, to communicate with the server.
Don't worry about how this works, all you need to use is the send function and C file input (use fread or fgetc, NOT fgets) int send(int s, const void *msg, int len, unsigned int flags);
s - a socket(you will use fd)
msg - data to send
len - number of bytes of data
flags - should be 0.
Finish the program so that it sends the requested file from the current directory through the socket file descriptor.
You can test your program using the html files in the paper environment in the labs - copy index.html and all the .gif files to the directory where the program is being run.
Start a web browser and go to https://127.0.0.1:3490/index.html. You may have to disable proxies for this to work in the labs. If you want, you can add extra error checking to the program to deal with bad requests.
Test the program by requesting a large file. While the file is being sent, use a different browser window to make another request, the second request should have to wait for the first one to finish.
Rewrite the program using threads so that it can reply to multiple requests at the same time. Do not use any global variables.
Submit your source code (the multi-threaded version) electronically from the web page in the labs or at home. Your submission must be a single source file written in ANSI C or C++. Your program should include comments as documentation.
This assignment may be done individually or in pairs. This assignment will be worth 10% of the complete paper. Late submissions will not be marked.