/*----------------------------------------------------------------------------*/ /* Program: survey2s.c (Assignment#4) "Server Application" /* /* Written By: Dan Swaney /* Class : CS476/576 - Unix Systems Programming (Instructor: Dr. Wahab) /* Date : November 10, 1997 /* /* Description: This program will: /* 1. Act as a server serving multiple client apps (survey2c) /* of which to collect data for a survey. /* /* 2. Display a master instructor window that displays results /* as they are compiled. /* /* Parameters: survey2s [time in minutes] [host server] [port address] /* /* [time in minutes] - timespan of survey of which users can /* participate users are notified of the result /* when timer reaches zero. /* [host server] - the machine name or IP address of where this /* server is to be running (e.g. buttercup) /* [port address] - enter a value between 1025 and 65535 /* (0 for random pick) /* The client must know this port in order to /* connect and participate in the survey. /* /* Example: %survey2s 5 buttercup 4001 /* (assuming you have an xsession on buttercup) /*-----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* Program: survey2c.c (Assignment#4) "Client Application" /* /* Written By: Dan Swaney /* Class : CS476/576 - Unix Systems Programming (Instructor: Dr. Wahab) /* Date : November 10, 1997 /* /* Description: This program will: /* 1. Act as a client participating in a survey that is managed /* by a server (survey2s) of which to collect data for a /* survey. /* /* 2. Display a user survey window that asks a question and /* gives the user a choice of Yes or No. /* /* 3. Notifies the User of the Results when the time expires. /* /* Parameters: survey2c [host server] [port address] /* /* [host server] - the machine name or IP address of where this /* server is to be running (e.g. buttercup) /* [port address] - enter a value between 1025 and 65535 /* (0 for random pick) /* The client must know this port in order to /* connect and participate in the survey. /* /* Example: %survey2c buttercup 4001 /* (assuming you have an xsession on buttercup) /*-----------------------------------------------------------------------------*/ // Short Description: // A Not-So-Simple Survey Tool (using XMotif and TCP Sockets) for Asking // a Question and getting survey results from other users in a limited // set time. Description ----------- The survey2s program creates a "professor interface" and allows the professor to type in a question and click the "Send" button. Each student user can then connect to the server via the survey2c program. This will display a "student interface" similar to the instructor. The question then appears on each "student interface" prompting the students to choose "Yes" or "No" by clicking a checkbox. When the student clicks "Send", their response is tallied for only the professor to see until the time limit runs to zero. The "professor interface" shows the number of users who have responded and uses a scale to show an estimate of whether all have responded. How to Compile -------------- 1. It is assumed that you have already configure the GNU gcc compiler and that you are using Solaris 2.51 with the Xlib and XMotif libraries. You may need to change the directories as needed in the file 'Makefile' should the compiler be unable to find certain files. 2. A script is provided called 'comp'. All you need to do is run the script and it will issue the appropriate make command to compile using the included Makefile for Solaris only. Trouble-Shooting Notes ---------------------- If you get errors from a file containing ".so." for a shared object, you need to add the location of this file to your LD_LIBRARY_PATH environment variable. If you get a message "gcc: Internal compiler error: program as got fatal signal 10" this will usually mean a hardware malfunction on the compiler's end, switch to a less heavily-trafficed machine and try to compile from there. NAME Survey2s / Survey2c : A not-so-simple client/server survey tool SYNOPSIS survey2s [time] [host] [port] survey2c [host] [port] DESCRIPTION The teacher invokes the program with one argument [time] to control how long (the number of minutes) the survey should last. In such case the program behaves as a server and displays the following message to the teacher's standard output: let each student type: survey2s host port where host is the IP address of the machine and port is the server port number. In addition the program displays a motif interface similar to the teacher's interface of assignment #3 with the following modifications. Replace the count-down counter with count-up counter, indicating the number of students who have been connected to the server. In addition, a time-left counter should be added to the interface indicating the number of minutes remaining until no further votes are accepted. Note that the count-down does not start until the professor sends the survey question. The survey results are displayed to the professor interface as they arrive (like assignment #3). However, only the final result of the survey is sent to all currently connected students at the end of the survey (when the time-left reaches 0). This, unlike assignment #3, the students are not aware of the partial results of the survey, they can only see the final result. When a student types: survey2c host port the program behaves as a client and establishes a TCP connection with the server (the teacher process). Upon the successful establishment of the TCP connection, the server sends to the client the number of minutes left until the end of survey. The student interface is similar to the student's interface of assignment #3, with only one modification: to add the time-left counter. When the time-left counter reaches 0, the student is not allowed to vote and the result of the survey is displayed (the result includes: the total number of students who have been connected to the teacher during the survey time, the number of YES votes and the number of NO votes). In this assignment, assume that the professor can not quit (i.e., disable the Quit button) until the end of the survey. However, the students may quit at any time during they wish.