Put all of the programs from this assignment is a directory called
assign5.
Use a separate subdirectory for each part.
Do not delete anything from assignment 4.
Part 0:
If you have not gotten Assignment 4 working at least through Part 3,
do this before starting the rest of the assignment. You do not have to
have the signals working for this assignment.
Make sure your fdreceiver
returns 0 if it gets an end of file when reading the first line.
Part 1:
Make sure you have completed Recitation 8. Copy the serverp and
client2 programs to a part1 directory under your
assign5 directory. Also copy all of the other files you need to
compile these programs. Create a makefile that can be used to
compile these programs. You can do this by deleting the appropriate
lines from the makefile you used for Recitation 8.
If running on Solaris, you may have to put back the -lsocket in the
NETLIBS line. Test the two programs to make sure they can
communicate with each other.
Part 2:
Copy all of the files from your part1 directory into a part2
directory. Copy fdreceiver.c and fdsender.c
from your Assignment 4 Part 3
into this directory.
Change the name of serverp.c to remotesender.c.
As you make changes, modify the makefile appropriately.
The remotesender program will now take two command line arguments,
a port number and a directory name. It will listen for connection requests
from the given port. When a connection request comes in, the child process
will send the regular files in the given directory to the network file
descriptor using fdsender just as filesender did, but
it will always use a sleep time of 0 seconds.
You can test this program by running remotesender with a directory containing a small number of short ASCII files. Connect to remotesender with client2.
Part 3:
Copy all of the programs from your part2 directory into a
part3 directory.
Change the name of client2.c to remotereceiver.c.
This program will take the same command line parameters as client2.c,
but after making the connection is calls fdreceiver in a loop
until an error or end of file occurs. As each file is received,
remotereceiver outputs a message giving the number of bytes
in that file. Before terminating, remotereceiver outputs a message
giving the total number of files transferred and the total number of bytes
transferred.
Note that you should be able to concurrently run multiple copies of remotereceiver with the same server.
Extra credit:
Copy all of your files into a new directory.
Rewrite remotesender so that it just takes a port number
as a command line argument. The child process will determine the
directory to send by reading a line from the remote host after
it makes a connection. The line will contain the name of the directory
terminated by a newline characters. No null character will be sent.
This program should reject any request that contains .. in the
directory name or has a directory name starting with "/".
Rewrite your remotereceiver so that it takes an additional command line argument, the name of a directory on the remote host. It sends this to the remote host terminated by a newline after establishing a connection. It then behaves as before.
Important note: Do not leave a copy of remotesender running, as it would allow others to get files from your directories.
Handing in your programs