CSE 532S Basic Networked Concurrency Studio

Please complete the required studio exercises listed below, along with any of the (optional) enrichment exercises that interest you.

As you work through the exercises, please record your answers in a file, and upon completion please e-mail your answers to the cse532@seas.wustl.edu course e-mail account with "Networked Concurrency studio" in the subject line.

Please make sure that the name of each person who worked on these exercises is listed at the top of your reply message, and that you number your answers so they are easy for us to match up with the appropriate exercise.

Visual Studio 2013 is not successfully compiling ACE on the Windows machines in Urbauer 218, so you should please use Visual Studio 2012 for this studio (and for subsequent studios and for the lab 3 assignment).


    Required Exercises

  1. As the answer to the first exercise, please give the names of the people who have worked on this studio.

  2. Download a zip file for the 6.2.1 Bug-fix-only beta version of the ACE C++ Network Programming library at http://download.dre.vanderbilt.edu/previous_versions/ACE-6.2.1.zip and unzip it into a location where you can use it on the Windows lab machines for your studios and projects for the rest of this semester (e.g., within the Projects folder under Visual Studio 2012).

    Optionally, you can download and install a zip file for the Doxygen documentation for ACE (and TAO and CIAO but you can ignore those) at http://download.dre.vanderbilt.edu/previous_versions/ACE-html-6.2.1.zip. Additional documentation for ACE can be found via various links from the main ACE web page at http://www.dre.vanderbilt.edu/~schmidt/ACE.html.

    Open up the ACE_wrappers folder that should have appeared, and then open up the ACE_wrappers_vc10.sln file it contains in Visual Studio 2012. If you get a message saying that it wants to open up the project's files in a local drive, please hit cancel to force ACE to be built on the network drive so that you can access it in future labs and studios. Once the file is loaded (loading it may take a little while) add a file called config.h to the ACE_wrappers\ace\ directory, which contains only the line:

    #include "ace/config-win32.h" save the file, and then build the ACE project, which should complete with no errors or warnings. Once you have successfully built ACE, as the answer to this exercise please give the fully qualified path to the directory in which you built ACE.

  3. Create two new projects in Visual Studio 2012 for this studio, for a simple client program and a simple server program written using ACE (e.g., named something like ACESimpleClient and ACESimpleServer). After you create each project, open up its project properties dialog window, and under Congfiguration Properties -> C/C++ -> General -> Additional Include Directories please give the fully qualified path to the ACE_wrappers directory.

    Also, under Congfiguration Properties -> Linker -> General -> Additional Library Directories please give the fully qualified path to the ACE_wrappers\lib directory, and under Congfiguration Properties -> Linker -> Input -> Additional Dependencies please add ACEd.lib (for the ACE debug DLL).

    In the C++ source files that should have been generated for those projects (e.g., named something like ACESimpleClient.cpp and ACESimpleServer.cpp), modify each main function's signature so that it takes an integer called argc and an array of C-style (char *) strings called argv.

    The client program should output an error message and return a non-zero integer if no command line arguments (besides argv[0]) were passed to it, and otherwise should print out the strings found in argv[1] through argv[argc-1] and then return 0.

    The server program should do the opposite, printing an error message and returning a non-zero integer if any command line arguments (besides argv[0]) were passed to it, and otherwise should print out the string found in argv[0] and then return 0.

    Save your code files and build and run each of your programs with and without additional command line arguments. Fix any errors or warnings that may occur, and as the answer to this exercise, please show the output of each program in each of those cases.

  4. Modify your ACE server program so that it uses an ACE_INET_Addr (constructed with an unsigned short port number and ACE_LOCALHOST a.k.a. "127.0.0.1" for the purpose of this exercise), an ACE_Sock_Stream, and an ACE_Sock_Acceptor.

    The server program should first call the ACE_Sock_Acceptor object's open method with the ACE_INET_Addr object and the value 1 (to be able to reuse the same address repeatedly), to have the acceptor listen on a given port (whose value should be greater than 1024).

    If that call succeeds (failure is indicated by a return value that is less than 0) the server program should call the ACE_INET_Addr object's addr_to_string method to obtain and print out a string indicating the address and port where the server is now listening.

    The server program should then call the ACE_Sock_Acceptor object's accept method once with the ACE_Sock_Stream object, to accept a singe socket connection.

    If that call succeeds (failure is again indicated by a return value less than 0), the server program should then use the recv method of the ACE_Sock_Stream repeatedly to read one character at a time from the socket and print it to the standard output stream, and then end once the socket is closed from the other side (indicated by the recv method returning a value less than 0).

    Make sure the program checks the value returned by the accept method of the ACE_Sock_Acceptor, and if it is less than 0 generates an error message and returns a non-zero value.

    As the answer to this exercise, please show your code and explain why it is important to check the return values of those methods (or of any method that can make a system call), and give an example of why that call could fail.

  5. Modify your ACE client program so that it uses an ACE_INET_Addr (constructed with the same unsigned short port number and ACE_LOCALHOST a.k.a. "127.0.0.1" as for the server), an ACE_Sock_Stream, and an ACE_Sock_Connector, to connect using the same port (and on the same machine) where your ACE server program will be listening.

    The client program should first call the connect method of the ACE_Sock_Connector object (which will return a value less than 0 if it fails) with the ACE_Sock_Stream and ACE_INET_Addr objects.

    If that call succeeds, the client program should then use the send_n method of the ACE_Sock_Stream object repeatedly to send all of the command line arguments that were given to the program, delimited by spaces, over the socket to the server, disconnect the socket (by calling the ACE_Sock_Stream object's close method), and then end. Make sure that the client program checks the values returned by the connect method of the ACE_Sock_Connector and the send_n method of the ACE_Sock_Stream, and if any return value is less than 0 generates an appropriate error message and returns a non-zero value.

    As the answer to this exercise, please show your code and explain why it is important to check the return values of those methods (or of any method that can make a system call), and give an example of why that call could fail.

  6. Build your updated server and client programs, fix any warnings or errors that you may see, run them (i.e., start your server and then start your client once the server is up and running), and as the answer to this exercise show the programs' input and/or output demonstrating that (different) command line arguments given to each client are sent to and printed out by the appropriate server, successfully.

    To run the ACE server and client, you will need to make the ACEd.dll file visible to Windows. One very straightforward way to do this is to copy it from the ACE_wrappers\lib directory into the directory where each of the executable programs resides.

    Enrichment Exercises (Optional)

  7. Play around with different combinations of multiple client and server programs, with a client connecting to several servers at once (having a server connect to multiple clients is more difficult and is something we'll cover just a bit later in the semester once we've talked about reactive and proactive event handling). As the answer to this exercise please show your code, explain what you did (using which libraries) and what you learned from that.

  8. Make your programs more flexible by taking additional information from the command line, from a file, etc. to allow them to run on different ports or on different machines easily. As the answer to this exercise please show your code, explain what you did, and describe what you learned from that.