Assignment 3: Writing a Pattern-based Web Client and Server

The purpose of this assignment is to deepen your understanding of reactive I/O, OO event demultiplexing, and active objects in the context of the ACE C++ toolkit. As before, we will write two programs: (1) a Web client and (2) a Web server. In brackets are some hints about what kinds of ACE frameworks and classes you should use.

In addition to the ACE C++ socket wrappers, the frameworks that you must use for this assignment are the ACE ACE_Reactor and ACE_Acceptor. The other hints are simply for your convenience. Graduate students are required to use the ACE_Connector on the client -- for ugrads this is optional.


Web Client

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 80) [ACE_Connector, ACE_INET_Addr, ACE_SOCK_Connector, ACE_SOCK_Stream].

  2. Send the request URL to the server, read all the content coming back across HTTP connection, and write the content to a temporary file created in your Web cache (e.g., using ACE_FILE_Connector::connect()) on the local host [ACE_File_Connector, ACE_File_IO, ACE_SOCK_Stream]. Make sure that the client won't hang indefinitely if the server fails to follow the HTTP protocol or of the network and remote hosts fail. For instance, make sure that all of your sends and recvs can time out after a fixed period of time has elapsed.

  3. As before, grad students should spawn an external viewer to display the file. You should determine the type of viewer using the MIME content type information returned by the server. Your client should parse this information and use it to determine which viewer to spawn.
The client should 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-threaded server program should do the following activities: