C++ Socket Programming

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. We will extend the previous C++ Socket assignment, using additional ACE C++ components in place of the lower-level C++ and C components. The new version will implement the same set of features as the previous version. As before, we will write two programs: (1) a WWW client and (2) a WWW server. In brackets are some hints about what kinds of ACE classes you might want to look up to do these (see ACE HTML manual pages and ACE references for additional details).

In addition to the ACE C++ socket wrappers, the component that you must use for this assignment are the ACE ACE_Reactor and ACE_Acceptor. The other hints are simply for your convenience (in particular, only use the ACE_Connector on the client if you feel comfortable using it).


WWW Client

The WWW 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 WWW cache (e.g., /tmp/yourloginname) 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. 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.
  4. Before spawning the viewer, the client should print out how much time was spent downloading the file [ACE_Profile_Timer].

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.


WWW Server

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