ASSIGNMENT 3

The purpose of this assignment is to learn how to exchange information between processes using pipes.

WHAT TO SUBMIT:

You will need four .c files at a minimum - client.c, server.c, parse.c and student.c. Two executables named client and server will be created. Use the test case file of the first assignment to test your program as in the first assignment.


PROBLEM DESCRIPTION

The program you write must have two parts to it - server and client. They are parent and child processes respectively. Create a bi-directional communication channel between them using pipes.


CLIENT

From the first assignment, use the parse module to parse the data from the file. Instead of calling APIs exported by the student module, it calls an API in the client module. The client module must pass the operation and the information related to the operation to the server side using the pipe. Then, it has to wait for a reply from the server on the read pipe to check whether the operation was successful or not. Finally, it has to send the operation "List" to the server side. The server sends all the database information to the client on the pipe. The client reads the data from the pipe and writes it to the output file. Once it has received EOF from the server pipe, it exits.

NOTE: The format of the output file is the same as that in the expected output file of the first assignment.


SERVER

The server is the module which interfaces with the student module of the first assignment. It reads data from the pipe on which the client sends the operations and information related to the operation. It calls the APIs exported by the student module. It sends the return value from the student module API as a reply to the client on its write pipe. When it gets the list operation, it calls the getrecord API from the student module and writes the data to the pipe to send the records to the client. It calls getrecord until there are no more records to get. At this point, the server has finished its job and will terminate.