Assignment 2 process communication via sockets Solution
The objectives of this assignment includes:
Learning about process communication via sockets
Apply the concepts learnt by developing a client-server program simulating a country search directory services
This assignment requires you to develop a client-server application using socket programming to simulate a simple ‘query’ search and info retrieval service. The characteristics are as follows:
Upon startup, the server program will read in a list of country data from a text file ‘countries.txt’, and store them in some data structure (e.g. array). Please refer to Appendix A, for a description of the fields in each line of record. Appendix B shows a sample of the contents in ‘countries.txt’ file.
After storing all the country data records, the server program will then create a socket, bind it to an address, goes into an infinite loop to listen for and accept a connection request.
Upon receiving a connection request, the server is to create a new child process to handle the client’s query. The child process will exit only when client indicates it is done searching for info, and the connection is then closed. While the child process is handling a particular client’s query, the parent process should continue waiting and listening for other client’s request for connection.
Appendix C shows an example of the server started in the background, with a message to confirm the startup status.
Upon startup, the client program will create a socket and initiate a connection to the server. Once connection is established, it will prompt user for input (i.e. the name of the country), before sending over client’s query.
Upon receiving server’s response, the client needs to handle 2 main situations:
· If the country’s data cannot be found, either because of mis-spelling in the query, or the country is non-existent, the client will output some error message to inform user
If the country’s record is found, the client will display some info about the country. (e.g. in Appendix D, the country’s capital city, and currency code are shown. However, you are not limited to display only these 2 fields. In fact, you can display whatever pieces of information that is available in ‘countries.txt’ file read in by the server).
Finally, Appendix E shows a simple simulation of multiple connections from 2 client programs started in 2 shell terminals. While it is difficult to demonstrate processing of multiple requests simultaneously (you need more than a pair of quick hands to do that), your server should be programmed in such a way to accept and handle at least two or more connections.
A) Please take some time to study the contents in Appendices A – E as they provide many useful information that could affect your program’s design, (e.g. how you should store each line of a country’s data as a record).
B) Before you start developing your program, you should take some time to review the output, and expected behavior, plan for basic error handling and analyze the requirements of the client-server socket application.
C) It is recommended that you come up with some basic table of technical requirements to document what you interpret to be desired functionalities of the program, before you proceed with program development.
D) Once the program is completed and tested to be working successfully, you are highly encouraged to add on “new features” to the program that you feel are relevant to the tasks of country directory searching services. Additional marks may be awarded subject to the relevancy and correctness of the new functionalities.
1) The deliverables include the following:
a) The actual working client-server program (hard+soft copies), with comments on each file, function or block of code to help the tutor understand its purpose.
b) A word document (hard+soft copies) that elaborates on:
· (Interpreted) requirements of the client-sever program
· Diagram / Illustrations of program design
· Summary of implementation of each module in your program
· Reflections on program development (e.g. assumptions made, difficulties faced, what could have been done better, possible enhancements in future, what have you learnt, etc)
c) A program demo/evaluation during lab session. You must be prepared to perform certain tasks / answer any questions posed by the tutor.
2) IMPT: Please follow closely, to the submission instructions in Appendix F, which contains details about what to submit, file naming conventions, when to submit, where to submit, etc.
3) The evaluation will be held during lab session where you are supposed to submit your assignment. Some time will be allocated for you to present / demonstrate your program during the session.
Student’s deliverable will be graded according to the following criteria:
(i) Program fulfills all the basic requirements stipulated by the assignment
(ii) Successful demonstration of a working program, clarity of presentation and satisfactory answers provided during Q & A session.
(iii) Additional effort (e.g. enhancing the program with relevant features over and above task requirements, impressive, ‘killer’ presentation)
(iv) After the submission of deliverables, students will be required undergo an evaluation process (to determine fulfillment of task requirements.) Further instructions will be given by the Tutor during the subsequent respective labs. Please pay attention as failure to adhere to instructions may result in deduction of marks.
In the real working world, satisfactory completion of your tasks is no longer enough. The ability to add value, communicate and/or demonstrate your ideas with clarity is just as important as correct functioning of your program. The grading criteria is set to imitate such requirements on a ‘smaller scale’.
(Description of fields in ‘countries.txt’ file)
Top Level Domain (TLD) code
Country’s code in FIPS104 standard
Country’s code in ISO2 standard
Country’s code in ISO3 standard
Country’s ISO number
Country’s capital name
Country’s region (e.g. Asia, Europe, etc)
Country’s currency name
Country’s currency code
(Sample contents in ‘countries.txt’ file)
Note1 : Each field in the country’s record is delimited by the comma ‘ , ’ character
Note2 : Countries’ name can be MORE THAN one word!
Note : ‘runServer’ is an executable shell script that executes the server program ‘css’. The ‘ps’ command verifies that the server program is started as a background process
(Sample output illustrating multiple client connections)
Submission Instructions (V. IMPT!!)
a) All submissions should be in softcopy, unless otherwise instructed
b) For the actual files to be submitted, you typically need to include the following:
- word document report (e.g. *.doc), save as MS Word 97-2003 format
- the source file(s), (e.g. *.sh, *.c, *.h, *.o, or *.cpp files)
- the executable file, compile into an executable file with *.exe
(e.g. Assn2.exe). Note: this only applies to non-shell script assignments!
2) How to package
Compress all your assignment files into a single zip file. Please use the following naming format :
Example : FT_Assn2_1234567_JohnDoeAnderson. zip
- <FT/PT Use “FT” for Full-Time student, “PT” if you are Part-Time student
- Assn2 if you are submitting assignment 2, Assn3 if submitting assignment 3 etc.
- <Stud. No. refers to your UOW student number (e.g. 1234567)
- <Name refers to your UOW registered name (e.g. JohnDoeAnderson)
3) Where to submit
Please submit your assignment via Moodle eLearning site.
In the event of UNFORSEEN SITUATIONS :
( E.g. Student's moodle account not ready, cannot login to moodle, eLearning site down on submission day, unable to upload assignment, etc )
Please email your single zip file to your tutor at :
[email protected] for FULL TIME students
(To be announced) for PART TIME students
In your email subject line, type in the following information :
<FT/PT <assignment info <student number and <name
To : tutor's email (see above)
Subject : FT Assn2 1234567 JohnDoeAnderson
Note 1 : The timestamp shown on tutor’s email Inbox will be used to determine if the assignment is late or not.
Note 2 : After email submission, your mailbox’s sent folder would have a copy (record) of your sent email, please do not delete that copy !! It could be used to prove your timely submission, in case the Tutor did not receive your email!
You'll get 1 file (29.0KB)