Part 1: Pointer to function and void*.
Read the man pages for qsort(3) and for strcmp(3). Is strcmp() suitable for use as qsort()'s comparison function? Are the return value of strcmp() and the types of the arguments the ones that you want? Perhaps you will need to wrap strcmp() with your own function in order to use this correctly.
Copy the file "sortArr.c" from Appendix 2. (Please provide your own makefile). It currently sorts an array of structures and prints them out in order of the 'height' attribute of the structure. Your task is change the program so that it sorts and prints them out in order using the surname as a primary key, and the given name as a secondary key.
Here are some tutorials on using qsort():-
Part 2: UML
Understanding UML Sequence Diagrams
(Goes in the report)
Take the time to understand UML sequence diagrams. Here are some references that may help:-
• "Using UML: software engineering with objects and components" by Stevens, Perdita; Pooley, R. J (available in USQ library)
• A Quick Introduction to UML Sequence Diagrams by Trace Modeller
1. Explain why some messages are unbroken, and some are dotted in UML sequence diagrams.
2. Explain what is meant by the "Alt", "Opt" and "loop" in UML sequence diagrams, and what role does the "guard" play.
Part 3: The demonstration networking server.
a) Modify the demonstration networking server.
Obtain a recent version of CscNetLib - at least version "1.7.4". You will find the program servBaseDemo.c. Copy it into your "Part3" directory, and rename it to "server.c". This will serve as a base for your server implementation.
The distributed sample code obtains the values "height", "width" and "depth" from the configuration and serves them to the client. You need to change it so that it no longer retrieves the depth width and height, but instead retrieves and serves the values of "PlatesDbase" and "SpeedExceed" in the "SpeedCamera" section of the configuration. Such a section does not exist in server.ini, so you must create it.
You must validate the presence of "PlatesDbase" and "SpeedExceed". You must validate "PlatesDbase" as being a plausible path name and validate "SpeedExceed" as being a positive integer.
The retrieval and validation of the values from the configuration must be performed in the initialisation routine that is passed to servBase_server().
Do not remove the statements in doConn() that print directly to the console, as they will help you in part d).
See the section on Hints, for useful hints.
b) Test the demonstration networking server.
(Goes in the report)
Test the demonstration server using a telnet client. Your testing needs to clearly demonstrate the following:-
1. That the demonstration network server works, providing the required file path. Terminate the server using a SIGINT signal, which can be generated from the keyboard using a <CTRL> C. Show the result in the log file.
2. That if "PlatesDbase" is not a decent and valid file path or if "SpeedExceed" is not a valid positive value, the demonstration network server will log an error saying so, and quit. Show the result in the log file.
3. Use multiple command line windows. Initially, set servModel to "OneByOne". Use a telnet command in each command line window, but do not enter the first line, so that the server is forced to wait for the line. Then type the lines as needed.
You need to show what happens when two clients attempt to connect to the server at once. Clearly explain what happened here, referring to the output of the server.
4. Now modify the server code so that the server uses a forking server model. Keep MaxThreads at 2.
Perform testing as before, so that it demonstrates what happens if you connect two clients at the same time. Clearly explain what happened here, referring to the output of the server.
5. Now show what happens when you attempt to connect three clients simultaneously.
6. Now change MaxThreads to 3 and demonstrate what happens when you attempt to connect three clients simultaneously.
Part 4: Plans for Implementation
There are marks allocated to Part4, but your marks for Part 5 will depend on your plans also.
You need to study Appendix 1 (the specification of the server that you will build) in order to do this question. Also, please take into account the code that has already been supplied to you for this assignment.