X Window Client Exercise

Due Date:

December 19, 1995

Deliverables:

The deliverables for this exercise are the same as for Exercise 3 except that you are to modify the sample program that I provided you to act as a graphical user interface for your client program.

When you have completed the exercise, send me e-mail telling me the project directory.

Requirements:

All you have to do for this exercise is to supply a working program; there is no requirement for additional documentation, although I will look at it if you provide it.

Description:

Your client program for Exercise 3 executed an algorithm that can be summarized as:

  1. Use command line arguments to establish a connection with the server.
  2. Obtain a command string from stdin.
  3. Send a command to the server.
  4. Read a reply from the server.
  5. Write a message to stdout.

For this exercise, you are to modify the sample program so that it replaces the client program that you developed in Assignment 3. Your server from Assignment 3 remains unchanged. The process can be thought of as adding your client program to the sample code or as adding the sample code to your client. At least for purposes of exposition, we will think of the sample program as a replacement for your client. That is, you will add parts of your client's code to the sample program.

First, you will need to extract the code for Step 1 of the above algorithm and add it to the main() function in file main.c of the sample program. The code has to be inserted after the application calls XtVaAppInitialize() so that any toolkit command line arguments will be removed before your program looks for the hostname and port number arguments.

The other part of the exercise is to take the remainder of your client program and edit it into the commandCallback() function in do_command.c. The sample program gets the command line entered by the user in an array named cmd, so you will have to do something so that either the code from your client uses this variable name or so the sample code uses your variable name instead of cmd. Whichever way you go, be sure the variable you use is declared as a char pointer rather than as a char array, since XmStringGetLtoR() mallocs the memory for the buffer, and has to be passed a pointer to a pointer rather than a pointer to an array.

Your client's interactions with the server can then use the same code as before in place of the sample application's use of popen() to process the user's command. You will have to change all printf() statements in your client so that they update the contents of the application's text widget, using the sample code in commandCallback() as a model.

One issue is how to manage the socket variable that is initialized in main() but which needs to be referenced in commandCallback(). The simplest solution is to make it a global variable.

Grading:

This exercise will count approximately 3% of your course grade. You will get full credit for constructing a program that combines the functionality of your Assignment 3 client with the user interface of the sample program. You do not need to add any functionality or fix any residual bugs in your code for Assignment 3 in order to get full credit for this exercise, assuming only that your program for Assignment 3 has at least basic functionality.

Good Luck!



Christopher Vickery
Queens College of CUNY