USQ CSC8415 2018 S2 Assignment 1
The assignment submission will have two parts, program code and a word processed report in PDF format. The code goes into the Git repository, and the report will be submitted using the USQ Studydesk assignment submission. Your work will not be assessed until you submit the report via the USQ submission. The submission date of your assignment is deemed to be the date of the USQ assignment submission.
Recall that in assignment 0, you learned :-
- The use of the Git repository.
- The use of a makefile.
- C command line arguments.
- Using pointers in C
- Calling functions in C
- Writing functions in C
- Encapsulation in C.
- Error handling
In Assignment 1, you will build on everything you learned in assignment 0. In addition to the above, you will learn :-
- Accepting TCP connections.
- Reading from TCP connections.
- Writing to TCP connections.
- Parsing HTTP text.
- Sending HTTP text.
- Opening and reading from file.
- Write a TCP server.
About this assignment
You will use CscNetLib networking library, beginning with the demonstrations in the Samples directory. You need to obtain the latest version of CscNetLib (i.e. version 1.9.0). The version number of the library exists in the file "std.h". Build it and install it, before attempting the assignment.
Network Framework Documentation
The documentation for CscNetLib routines exists in the network framework header files, and you will need to read these carefully in order to complete the work in this assignment.
For example, if you want to know just what a given netCli_???() routine does, and what the return value is, you will find the documentation for the routine immediately before the prototype for that routine in the file "netCli.h" in the place where you installed it.
If you get stuck
If you are stuck at any stage which is likely then seek help on the forums. Hopefully someone has already had the same problems as yourself, and you can read the solution in the forums. If not, then you need to ask.
Develop a bit at a time.
It is good practice, and in this course your marks depend on it. You need to plan your delta (small improvement) so that your increment can be tested. Get the delta working and test that before moving on.
You MUST check your work in with Git
You need to check your code into the Git repository provided for this course (NOT GitHub), and push it to the server regularly. This is good practice normally, and in this course your marks depend on it. There are marks associated with your report, but failure to check in your code regularly will incur the loss of the marks associated with the code. Code with no development history is worth zero marks.
Figure 1: The process of developing your code.
Checked into the correct place
You may need to make a new directory in your Git repository called "Ass1", and it will have subdirectories within that directory as needed.
The student is expected to produce quality code. The code should be:-
- Consistently formatted throughout using Horstmann, Allman or K&R indent style, with Allman being preferred.
- Block commented.
- Not use many global variables.
- Use modules (functions).
Testable on Linux
Your marker will inspect, compile and run your code on the Linux operating system as provided for this course. If it does not work on the linux test machine then the marker will say that it does not work.
It builds using make
The marker will go to the directory associated with the question and inspect the code. He or she will type the command "make" in order to compile the program.
No errors or warnings
Errors mean that it does not work, but compiler warnings will cost marks. Compiler warnings are usually an indication of something not being done correctly. If you cannot ascertain the cause of a compiler error or warning, then seek help in the tutorials or the course forums.
Submit the report
Your work will not be assessed until you submit the report via the USQ submission. The submission date of your assignment is deemed to be the date of the USQ assignment submission.
(Goes in the report)
- (2 marks) Explain in your own words the purpose of each of the "words" or "fields" of a request line.
- (1 marks) Explain how the parameters of a CGI GET request are bundled into the request-URI.
- (1 marks) Explain percent encoding.
- (2 marks) Explain in your own words the purpose of each of the "words" or "fields" of a response line.
- (1 marks) What is the purpose of the "host" header of a request, and why it is mandatory.
- (1 marks) Explain the Content-Type header. What is the difference between "text/html" and "application/html".
Observing HTTP in action
- (1 mark) Use telnet to download the file "index.html" from http://example.com. Show the command and the output in report.
- (1 mark) Use telnet to attempt to download the file "wontBeThere.html" from http://bology.com.au. This one times out pretty fast, so you will have to be ready to paste your HTTP request into your telnet conversation. Show the command and the output in report.
- (2 marks) Build and test netSrvDemo. You will need to use two command line windows to do this. In one command line window, invoke netSrvDemo. In the other command line window, invoke the telnet command with the host "localhost" and the port number 9991 as arguments. Type some text, and press enter. Take screenshots of your two command line windows and paste them into your report.
- (4 marks) Copy the function main() from netSrvDemo.c into your report, and comment every line of code.
You will implement a very basic HTTP 1.0 web server, with error handling, that can deliver files. You can test your server using telnet while you are developing it, but when completed, you should be able to point a standard web browser at it.
You may well be able to re-use nearly all the code from assignment 0.
* Initialise logging.
* Read configuration.
* Initialise server object.
* Get a connection
* Read only the first line (which should be a request line).
* Split the line into words
* if there are the wrong number of words.
* Send appropriate HTTP rejection. (status code 400)
* else if the request is not "GET"
* Send appropriate HTTP rejection. (status code 501)
* else if the file is not a decent absolute path
* Send appropriate HTTP rejection. (status code 404)
* else if the file does not exist in the configuration directory
* Send appropriate HTTP rejection. (status code 404)
* Send appropriate HTTP acceptance. (status code 200)
* close the connection and free resources.
Keep it simple. This assignment requires only a very basic server. We are using the protocol HTTP/1.0 in your response so that you dont have to provide any headers that give the length of your file. Just close the connection when you have delivered the file. You will still have to end the HTTP message using a blank line.
Reading a line and splitting into words.
Instructions are given on the course home page.
Concatenating the server filesPath and the requested URL
The use of csc_alloc_str3() is suggested, but remember that you have to free() the result after you have used it.
Transferring file data
The use of csc_xferBytes() is suggested.
Implement a bit at a time.
- Initially just implement HEAD (i.e. HTTP message and no file delivered), and test it with telnet.
- Later write a function to deliver the file. If you have such files as "notFound.html" and "notImplemented.html" then this can also deliver the explanatory text in response to anomolous requests.
(Goes in the report)
Use telnet to demonstrate what happens when the request involves:-
- The wrong number of words in the request line.
- The request is not "GET"
- The file requested is not a decent absolute path
- The file does not exist in the configuration directory
- Successful deliver of the requested file
Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak: