CSCI 631 Section 1 Assignment 2 Implementation Notes

This document discusses the manner in which assignment 2 will be graded for students in section 1.

Note that you must provide your own version of in_out.c that will provide implementations of writen() and readline() as discussed in the UNP text. You will want to use these functions when writing and reading to/from sockets in your client and server applications. These functions should be taken from UNP section 3.9. You will replace the #include "unp.h" with the appropriate system header files as demonstrated in class. You can save typing time by downloading the UNP book source code as shown in class and extracting the functions from the following files:

lib/writen.c
lib/readline.c

Copy the functions from the above files into in_out.c and in_out.h:

Your Client Application

Implement your client application according to the following usage statement:

Usage: prog2_client <IP-number> [<port-number>]

As such the IP number to connect to is required and the port number is optional. The default port number shall be 9880.

Note: It is implied that the socket used to connect to the server will be opened once and then used to send zero or more queries.

How To Test Your client Application

Once compiled on tiger, you can either use the echo service or nc -lk to simulate a server suitable for testing your application. (The echo service is available on tiger on TCP port 7.)

The assignment says nothing about the specific format of the response text messages. You have to be prepared for anything. Clean up any trailing whitespace that might be part of the response messages and render the result in the manner shown below.

Here is an example of what you will see if you test your application using the echo service (...that we know will simply reply with the string that your client sent to it.)

[winans@tiger]$ ./prog2_client 127.0.0.1 7
Book title: 1985
Author of book: '1985'
Book title: 1984
Author of book: '1984'
Book title: Hobbit
Author of book: 'Hobbit'
Book title: Frankenstein
Author of book: 'Frankenstein'
Book title: ^D
[winans@tiger]$ 

Notice the format and spacing of this example output. Quotes have been added to the response text from the server to clearly show that any trailing whitespace characters have been removed. You are expected to do the same.

Note that prog2_client allows an optional second command-line argument to specify a port number. You will want to use it to connect to a server on another port like nc -l 1234 | hexdump -C in order to see the raw data byte values that it sends:

[winans@w520]$ nc -l 1234 | hexdump -C
00000000  48 6f 62 62 69 74 0a                              |Hobbit.|
00000007

Your Server Application

Students in section 1 will implement their server application according to the following usage statement:

Usage: prog2_server <book-database-filename> [<port-number>]

This is different from the assignment handout in that you must provide the name of the book database file on the command line. This allows you to easily create and test your app with different files and/or on your own PC for testing. The default port number shall be 9880.

Once compiled on tiger, you can either use your client application to test your server OR you can notice that the protocol described above is identical to what is sent from the nc command if it were connected to your server.

The book database file contents are shown below:

Hobbit:Tolkien:
Candide:Voltaire:
1984:Orwell:
Frankenstein:Shelly:
Introduction to C++:Steve Heller:
Making TEX Work:Norman Walsh:
Preparing Proposals:Meador:
Local Computer Networks:Joseph Hammond and Peter O'Reilly:
A First Course in Probability:Sheldon Ross:
The Theory of Numbers:Albert Beiler:

If I start the book server and listen on the loopback address port 12345 like this:

[winans@w520 prog2]$ ./prog2_server book.d 12345

... I can then connect to it using nc and type in book titles, then it makes sense that it would look like this:

[winans@w520 prog2]$ nc 127.0.0.1 12345
Hobbit                               <---- I typed this line and pressed enter
Tolkien                              <---- Server responded with this line
12345                                <---- I typed this line
unknown                              <---- server response
1985                                 <---- I typed this line
unknown                              <---- server response
1984                                 <---- I typed this line
Orwell                               <---- server...
Preparing Proposals
Meador
The Theory of Numbers
Albert Beiler
Introduction to C++
Steve Heller

Note that some of the book titles have spaces in them.

Assuming that you run your server and client on the same host... here is the same set of book titles entered into my implementation of the client program:

[winans@w520 prog2]$ ./prog2_client 127.0.0.1 12345
Book title: Hobbit
Author of book: 'Tolkien'
Book title: 12345
Author of book: 'unknown'
Book title: 1985
Author of book: 'unknown'
Book title: 1984
Author of book: 'Orwell'
Book title: Preparing Proposals
Author of book: 'Meador'
Book title: The Theory of Numbers
Author of book: 'Albert Beiler'
Book title: Introduction to C++
Author of book: 'Steve Heller'
Book title:

Again notice the quote marks are added by the client application to indicate that the author text is properly trimmed before it is printed.

Note also that you SHOULD test your assignment by running your server on lambda.onyuksel.net (99.89.218.77) and client on tiger.cs.niu.edu.

Makefile

Here is the Makefile that will be used to grade the homework for section 1. Note that this Makefile will produce a client application executable named prog2_client and a server application executable named prog2_server

In order to use this Makefile, place it in the same directory as your source files and then type make world.

How To Hand In This Assignment

To hand in this assignment, execute the following command on tiger:

~courses/bin/mail_prog.631 prog2_client.c wrapper.c wrapper.h in_out.c in_out.h query.c query.h prog2_server.c serv.c serv.h

Last modified: 2018-05-28 11:04:55 CDT