Assignment 2: Writing a Process-per-Request Web Client and Server

The purpose of this assignment is to deepen your understanding of the ACE C++ toolkit to perform network IPC between two host machines. We will expand assignment 1 by again write two programs: (1) a web client and (2) a more robust web server that uses multiple processes rather than multiple threads to process requests. In brackets are some hints about what kinds of ACE classes you might want to look up to do these, which are described in the ACE books and ACE online documentation. The components that you must use for this assignment are the ACE C++ socket wrapper facades and ACE_Process_Manager. The other hints are simply for your convenience.


Web Client

As before, the web client program should do the following activities:
  1. Read the URL and the server port number from the command line. Create a socket that is connected to the server machine at the specified port (e.g., HTTP port 8080) [ACE_INET_Addr, ACE_SOCK_Connector, ACE_SOCK_Stream].

  2. Send a request to the web server using the HTTP protocol format. This will look something like this:
    
    GET /index.html HTTP/1.0\n\n
    
    Note that it's very important to include the two trailing newlines -- they are required by the HTTP protocol.

  3. Read all the data from the HTTP connection and write it to a temporary file created in your web cache (e.g., /tmp/yourloginname) on the local host [creat,read/write].

  4. The following portion of the web client is just for the graduate students in the class. Spawn an external viewer to display the file. You can determine the type of viewer to spawn in two ways:

The client should simply print out the appropriate error message [perror] and exit with a return status of 1 if any of the system calls fail to work properly. If everything works correctly, the program should exit with a return status of 0.


Web Server

The concurrent multi-process server program should do the following activities:


Comments

Although this assignment is fairly easy to describe, there are some subtleties involved in making it work correctly. In particular, you will need to learn about many details such as network addressing, remote host identification, signal handling, process creation and termination, etc.

In addition, please note that although we will use the ACE C++ socket wrapper facades, you can actually communicate between processes on the same host for testing purposes. However, the same programs will work for communicating between processes on two separate host machines, i.e., only the addresses will be different!


References