CSCI 342: Networks

Semester: Spring 2013
Room: King 227
Class Time: Mon/Wed/Fri 2:30pm-3:20pm
Office Hours: Monday 3:30-4:30pm
Thursday, 4:30-5:30pm
or by appointment
Professor: Cynthia Taylor
email: ctaylor AT oberlin edu
Please include "cs342" in the subject.
Office: King 229
Phone: x58424

A Simple Web Client

For this week's programming exercise, we will create a truly barebones web client. Based on the example tcp client code in hw1.zip, and the http example sessions shown in class, write a command-line program called hw1 that takes a URL as its only parameter, retrieves the indicated file, and stores it in the local directory with the appropriate filename. If the URL does not end in a filename, use 'index.html'. Make sure it works for both text and images by opening the stored file in a web browser. You may assume that the URL is on the form http://host/path, where path may or may not be an empty string, may or may not contain multiple slashes (for subdirectories), and may or may not contain a file name. You may assume files to be no larger than one megabyte, and you are not expected to handle HTTP redirect (3xx) return codes other than report them.

The hostname may be a name like www.google.com, but the example code requires an ip address (like 128.30.87.92). To look up the IP address of a given host name, use gethostbyname() or getaddrinfo(). "man 3 gethostbyname" on the command line will give you the details, or consult the gethostbyname or getaddrinfo example.

A few hints:

Handin

We will be using Handin to turn in all assignments. Turn this in for class 342, assignment 1.