CS 596 Client-Server Programming
Past Exams
[To Course Home Page]
San Diego State University -- This page last updated March 18, 1996
Contents of Past Exams Lecture
- Midterm
- Final
Here are the exams given in this course last year. The
course has changed a lot from last year. This means that some of the questions
from these exams to not apply this year.
1) Given the state machine below, outline an implementation for it in C
or C++ that does not use switch statements. Explain the data structures and the
operations in your solution.
2) The POPUP protocol has six commands: USER, PASS, QUIT, FINGER, DATE,
and LIST. None of the commands has any arguments. Before anything can be done,
the USER command must be given. At this point the FINGER, DATE and PASS
commands can be issued. Once the PASS commands has been given it is also
possible to use the LIST command. One can always issue the QUIT command. When
an illegal command occurs an error occurs. POPUP does not recover from errors.
Draw a state diagram for this protocol.
3) a) What are the benefits of using name/value pairs as opposed to
positional parameters?
b) What are the benefits of using positional parameters as opposed to
name/value pairs?
4) a) What are some of the advantages of a centralized multi-user system
over a client-server system?
b) What are some valid reasons that management might resist using
client-server systems, even when working with computers connected to LAN?
5) a) Why would one use inetd to start a server instead of a command
line.
b) Give two ways to detect that your program was started with inetd
rather than with a command line.
6) Comment on the style of following server program. If there is a
"problem" with the code, indicate what the problem is and where it occurs. If
there is something "good" about the code, indicate what and were. All syntax
errors are typos and can be ignored.
char *pn; /*parent name*/
main(int argc, char** argv)
{
int sockFD, new_sockfd, cllen, chPid; /*cl = client, ch = child */
struct sockaddr_in cl_add, sAdd; /*s = server, add = address */
pn = argv[0];
if ( (sockFD = socket(AF_INET, SOCK_STREAM, 0) ) < 0 ) /* open socket */
ExitOnFatalError("Can't open Server Socket");
/* Bind local address */
bzero((char*) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(6666);
if ( bind(sockFD, struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0)
ExitOnFatalError("Can't open Server Socket");
listen(sockFD, 5);
/* infinite loop */
for ( ; ; ) {
cllen = sizeof( cl_add);
new_sockfd = accept(sockFD, (struct sockadd *) &cl_add, &cllen);
if ( chPid = fork() ) < 0 )
ExitOnFatalError("Fork Error");
else if ( chPid == 0 ) {/* child process */
close(sockFD); /* close original socket */
Handle_Client_Request_On_Socket( new_sockfd ); /* process the request */
exit(0);
}
close( new_sockfd ); /* parent process */
}
}
7) What are the advantages and disadvantages of using UDP over TCP?
8) Joe has a stateless server that allows clients to read information
from files on the server machine. Clients frequently make multiple back-to-back
request for information in the same file. Since opening and closing files is
time consuming, Joe decides to keep files open between client connections. What
problems might Joe have in doing this? Is it advisable?
9) Since we have at least two methods of implementing state machines,
why avoid stateful protocols? For example, why not make Gopher+ a stateful
protocol. It would make interactive queries between the client and server
easier to implement!
1) What problem(s) does the lack of preemptive threads or processes in
Microsoft Windows create in writing client-server applications?
2) a) What is the purpose of building a prototype of a
user-interface?
b) What problem(s) of software prototyping tools is lo-fi or paper
prototypes trying to solve?
3) What are the disadvantages of using fixed-length records in a
database?
4) a) What is a scenario? Why are they important?
b) Give a scenario for the Room scheduler program.
5) Why might logging be important in client-server applications? What
type of information might be important to log?
6) Why might concurrency arise in a client. How might one implement
concurrency in a client?
7) Servers can be categorized as concurrent or iterative, connectionless
or connection-oriented. This gives four different types of servers. Under what
conditions would you use each type of server?
The next two questions are related to the ExamOracle. The ExamOracle
client-server application is a clandestine operation run by students. Clients
run on small wireless PDAs, which look like calculators. The ExamOracle
protocol is stateless. Messages are 1K or less. A message to the server
contains a short question (which a student needs answered.) The server response
is either a short answer or an error message.
8) Assume a server for the ExamOracle protocol is only going to be run
using inetd. We have two functions already written for ExamOracle protocol X:
isValidQuestion and answerToQuestion. isValidQuestion accepts a string, and
returns true or false depending on if the message was a valid message for the
ExamOracle protocol. answerToQuestion accepts a valid question and returns a
string containing the answer. Write a server program for the ExamOracle
client-server application.
9) The current database of answers requires question, the instructor's
name, the course and the type of question (true-false, multiple choice, essay)
before it can return an answer. Design a protocol for the ExamOracle
client-server application.