Due: Thurs. 23 2008
Download the tar file ex2-tcp.tar, untar it, compile it and run it on a couple remote machines.
Find an introduction to TCP BSD socket programming and read it.
Read the code from the example and man pages on your system for the system calls used.
Find an introduction to make, read it, and read the Makefile for the example so you can modify it in this assignment.
Write wrapper functions to make a simple to use TCP socket library libmysocket.a and an include file mysocket.h. Include functions to read and write messages. Use make to automate building the library. A suggestion for mysocket.h is in mysocket.h .
Rewrite the example programs using your library, using make to automate the compiles.
You can look at ex2-lib.tar for an example of using a Makefile to build a static library. The example also shows how to use a library, with it's include file, to build a program. Be sure you understand the Makefile and could modify it.
Write a C program my_cp that copies files.
Useage: my_cp to-file from-file
Use open(), read() and write() and be sure it will work on named pipes.
The exit status should be 0 on success and 1 on error.
Use a prpper Makefile to both compile and run sone tests on your program.
Add functions to your library (and header file) to send and recieve "messages".
int myTCPsend(int socket, int type, char *mess, int meesLen);
int myTCPrecieve(int socket, int *type, char *mess, int messLen);
The suggested internal format for a message is:
sync marker: 4 bytes
message legnth: 4 bytes
message type: 1 byte
message payload: message legnth bytes
Be careful that the function work between big endian and little endian machines.
Use a proper Makefile to compile your library and test these functions, before proceeding.
mycp [port] -ppassword name@domain-name:remote-path local-path
mycp [port] -ppassword local-path name:remote path
mycpd [port]
Be sure the exit status reflects the result.
Use your libary and a proper Makefile to both compile and test your functions.
You will demonstrate your system to the instructor. You must have automated testing and a reasonable number of tests.
Why should SSL or IPsec be used instead of straight TCP in many/most applications?
Explain how a "streaming" protocol with sliding windows will improve preformance over a "ping-pong" protocol.
How could you allow restarting a transfer if a connection was broken?
How could you use fork() in the deamon to allow multiple transfers to occur?
How could the deamon create a log file?
How could you detect a memory leak in your deamon.
How could you prevent more that one copy of the deamon from runing at as time?
For exxtra credit you an use the alarm() system call to creste time outs
as part of your protocol. You could add a