Your server is to wait for connections on a port above 1024. When a web client connects to it, your client should determine which page the client is asking for, download that page, and send that page to the client. However, if the page is from microsoft, you should abort the download with an error page.
To use this program, you will want to set your explorer to use a proxy
server. See "proxy server" under the help section.
Note that the default is to NOT use http/1.1 with proxy servers.
There is a program in in this directory that you can run to see the request that explorer sends.
The main structure of your program might look like this ...
main() sock = accept( ... ) fork() if i am the child read the request parse the request finding the URL they want download the URL send the URL exit if there was an error in fork print "Oops" if i am the parent close the socket from acceptCan handle commands that are sent in mutiple writes in your program. That would have to look more like ...
main() sock = accept( ... ) fork() if i am the child while not finished call select if data available add it to the request buffer else if timeout leave while loop parse the request finding the URL they want get the data send the data if there was an error in fork print "Oops" if i am the parent close the socket from accept
More Hints
Points | Task |
10 | Can accept a request from a web client |
10 | Can parse the request finding the URL to download |
10 | Can copy the URL from the server to the client |
30 | Can handle more than one connection at a time (uses fork) |
30 | Can combine multiple reads into one request (uses select) |
40 | Has a cache
I don't expect most people to get this ... but suprise me! |
30 | Stops all pages from microsoft (or some other place) |
10 | Keeps a log file |