This project has three goals:
The code of simplex-talk is the basis for this project. Migrate the networking code form simplex-talk into simple-data as needed. To understand this code, refer to Beej's Guide to Network Programming (thank you Brian Hall!).
Copy the [repo]/class/simple-talk folder to your folder [repo]/[user]/simplex-talk folder, compile and run. The makefile does a local run. Please read the makefile and code carefully and experiment by running the server and client on different machines in the lab.
To benefit from this code, as you migrate it, you must read it, grok it, even adore it
Finally, accomplish the task of this project. Copy the template files [repo]/[class]/proj1 to youre [repo]/[user]/proj1 folder, add and commit with message -m "initial commit". Work your changes, committing when you reach a subgoals (at least). Commit on the due date with the message -m "submitted for grading".
NAME
simple-data-s, simple-data-c --- client/server pair to send a message and a number
SYNOPSIS
simple-data-s [-vx] [-p port] [-l count]
simple-data-c [-vx] [-p port] host message number
DESCRIPTION
Server listens on the default port, or port given by the -p option, for a data
packet from the client. It prints out the message and number on separate lines and
then repeats for count repetitions then exits. It repeats forever if count is 0,
which is the default.
Client sends a single data packet to the host at given host, with message and number
according to the data format. Message is a text message of equal or less than 255
bytes, and number is a four byte integer, signed, integer.
OPTIONS
-l server is to receive count messages and exit. Default is 0, which means to loop forever
-p port for client to send to, server to listen on. Default is port 5432.
-v verbose
-x use little endian order. Default is to use network byte order
ARGUMENTS
Host, the name of the host the client will send the data packet to.
Message, a 255 or fewer byte text message
Number, a four-byte, signed integer.
OUTPUT
Without verbose options, server is silent except for printing each message
and number of two separate lines. The message is printed between two pipe
characters ("|") and any non-printable characters are printed as a dot (".").
HISTORY
New for csc424-182.
You are to send by TCP a data packet of n+5 bytes, where n is the text message length. The first byte is n. Note that this means messages are at most 255 bytes long. The null termination byte is not sent among the characters. Immediately following the message is the number, as a 4 byte, two's complement integer in network byte order.
0 1 2 ... n n+1 n+2 n+3 n+4
+-----------------------------------+
|len| message | number |
+-----------------------------------+
The number can be in little endian by the -x option.
Students often confuse a number and the "picture" of a number. The number 123 in this instance would be the value 0x7b packed network byte order into 4 bytes, 0x00, 0x00, 0x00, 0x7b. It is not the text string "123", as in the 4 byte sequence 0x31, 0x32, 0x33, 0x00.
The message need not be a string. In testing, it is hard to test a non-string message because command line arguments are necessarily strings. Students often error on their handling of the null string termination character. The string "hello" must be sent as exactly 5 characters, without the null termination character. To print the received message, the server code will put back the null terminator.

author: burton rosenberg
created: 25 jan 2018
update: 25 jan 2018