CSCI 6356 Fall 2000
Xiannong Meng Programming Assignment Three
Assigned: Thursday November 2, 2000 Due: Thursday
November 16, 2000
In this assignment you will use pthread to write a program that
can retrieve web pages automatically. The main thread accepts a
request from the user. The request should include the URL and an
optional file name in the following form:
url filename
For example www.cs.panam.edu index.html
meaning the user wants
to visit the site www.cs.panam.edu
and requests a specific file
index.html
. Once receiving the request from the
user, the main thread forks a work thread and the thread will be
responsible to retrieve the page specified by the user. While the
thread is working on the user requested page(s), the main thread
should return to handle more user requests. At any moment there could
be multiple threads working on multiple requests from the user. The
main thread also needs to keep a counter as how many requests have
been serviced.
The HTTP Protocol
To retrieve a web page, the client and the web server need to
communicate with each other using a fixed protocol. This protocol is
called the Hyper Text Transfer Protocol or HTTP for short. The
protocol itself is evolving. But the following is a sequence of basic
steps how the two (the server and the client) communicate.
client: Open connection at www.cs.panam.edu client: Send request: GET / HTTP1.1\n\n server: Send back the page http://www.cs.panam.edu/For details of how this works see the program example at
Pthread
The Pthread has been discussed in the class. Click
<http://www.cs.panam.edu/~meng/Course/CS6356/Handout/Pthread/>
for more examples.
Hand in: Please email me by the due date the location of your program in our lab computers. I'll go there and check it on-line. For those who work outside our lab, please ftp your program to the lab so that I can check them on-line.