Homework 2Due Tuesday, April 22th, at the beginning of class. Reading AssignmentRead Chapter 3 Tanenbaum Written QuestionTanenbaum question 4-40, 4,-36, 4-8, 4-29 Programming ExerciseThe point of this assignment is to get started with basic network programming skills and become familiar with web server protocols. Step 1Download lab2.tar.gz into your home directory. Uncompress and expand the file with the following commands: > gunzip lab2.tar.gz > tar xf lab2.tar Step 2The webcat program, will read and output a page from a web server in ascii text. As provided, the program will read a web page from a server and port number which is compiled into the program. Your first modification is to change the program to read the host, port and page information from the command line. This will involve using the standard UNIX varargs functionality to read the command line. Webcat should have the following syntax: webcat http://<host>[:<port>][/request] (port and request are optional) Webcat should also check that the options are right and that the URL is well formed. When no URL is passed, www.cs.uchicago.edu will be assumed. When no port number is passed, port 80 will be assumed. When 'request' is not passed, the string "/" will be assumed. Webcat should parse the URL and pass the corresponding host, port, and request values to connectHTTP(). Step 3Webcat reads character by character, which is very inefficient. Change webcat to read blocks of 1024 characters. Your version of webcat should also check for errors from read and connectHTTP(). Step 4Write a small program, tfromzip, which provides the current temperature given the local zip code by connecting with the weather channel web site. Syntax should be: tfromzip 60637 And the return should be the local temperature for the zip code 60637, according to weather.com. A sample program, in the form of a shell script, which uses the text web browser lynx, is included with the webcat source. Modify a copy of webcat, or write a small c program which calls connect HTTP. You must use webcat or connectHTTP, do not use lynx like the sample script does. [The temperature shell script is fixed in the tarball, thanks to Andy's suggestion, or you can just get the shell script here.] DeliverablesPlease turn in your source for webcat.c and tfromzip and a typescript (output from the script program) showing both programs running, including a bad URL to show error processing. Please email these items and the question answers to the grader for this week. Please try to limit the amount of extra stuff in your typescript. |
||