Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems.

Similar presentations


Presentation on theme: "CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems."— Presentation transcript:

1 CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems

2 CS-3103 & CS-502, Summer 2006 Programming Project #32 Programming Assignment 1.Build a simple but real web server using sockets 2.Build a simple web client for testing your server 3.Make your server fork a process or spawn a thread for each new request

3 CS-3103 & CS-502, Summer 2006 Programming Project #33 Purpose To gain some insight into sockets and communication over networks.

4 CS-3103 & CS-502, Summer 2006 Programming Project #34 Part 1 – Web Server Create a socket() and bind() it to a port. listen() on that port for requests Wait for requests; upon receipt of a request –accept() the request –Interpret the HTTP protocol –Find and deliver the page; or return an error –Close the accepted request –Loop back and wait for another request Figure out a way of exiting from the server cleanly.

5 CS-3103 & CS-502, Summer 2006 Programming Project #35 Part 1 – Web Server (continued) Command line:- % server [optional port #] Directory is prefixed to every request. –WPI directory for web pages is /www/docs Port is port number for your server –You may specify a default port in your code, but don’t choose one to conflict with another student! –Warning: Unix does not let you reuse ports until after a reasonable waiting period (30 seconds?) A request to your server of http://ccc4.wpi.edu:4242/admissions.html means ask the listener of port #4242 to return the file at /www/docs/admissions.html

6 CS-3103 & CS-502, Summer 2006 Programming Project #36 Part 1 – Web Client Simple test program that requests web pages and prints out their contents. Use to see what your server is doing. Use to see what another server is actually serving when you request the same pages. Use it to gain insight into details of HTTP protocol

7 CS-3103 & CS-502, Summer 2006 Programming Project #37 HTTP commands Your server must interpret HTTP GET command See written project description for examples All command lines must end with CR/LF –i.e., in Unix \r\n Series of HTTP commands ends with blank line –i.e., a stand alone \r\n

8 CS-3103 & CS-502, Summer 2006 Programming Project #38 HTTP Response Once you accept a command and have found the page, respond with HTTP success response 200 –See written project description –Be sure to follow with a blank line If you cannot find or read the page, respond with HTTP error response 404 You only need to serve real file pages. –Ignore scripts, etc. WPI’s home page is a script. –Remember: some pages are not all text!

9 CS-3103 & CS-502, Summer 2006 Programming Project #39 Sample code See http://www.cs.wpi.edu/~cs502/s06/CodeFragments/ Includes sockserver.c sockclient.c sockreadline.c

10 CS-3103 & CS-502, Summer 2006 Programming Project #310 Part 2 – Multi-process or multi- threaded web server Modify your web server to fork() a process or spawn a thread each time it receives a request. This allows it to serve multiple requests in parallel. Test with multiple web clients or browsers in parallel. Be sure to clean up “zombie” processes on the fly –Use wait3() Be sure that your server leaves time for each process to finish before exiting cleanly.

11 CS-3103 & CS-502, Summer 2006 Programming Project #311 Project Submission Project due at start of class on June 29 (i.e., last class of the term for CS-3013 students) Submit via turnin command = ‘ /cs/bin/turnin ’ on CCC machines classname = ‘ cs502 ’ assignment = ‘ project3 ’ Include Code, makefiles, test files or input, test output

12 CS-3103 & CS-502, Summer 2006 Programming Project #312 Format of submission Write-up Makefile to make all, clean, each part Source code files (.c,.cpp,.h, etc) Any test cases Any output logs All at top level: No subfolders No zip files


Download ppt "CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems."

Similar presentations


Ads by Google