CS 3733 Operating Systems, Fall 2003 Assignment 5


Due Tuesday, November 25, 2003, before class

This assignment is a continuation of Assignment 4.

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

  1. Test of Part 2
    Execute remotesender with the directory
    /usr/local/faculty/share/cs3733/assign5/part2
    Connect to this using client2 running on a different machine.
    Gather and save the output generated by client2.
  2. Test of Part 3
    1. Run remotesender as before but connect to it using remotereceiver running in a clean directory on a different machine. In this directory execute ls -l and save the result. Save the output generated by remotereceiver.
    2. Do a) again having remotesender use the directory
      /usr/local/faculty/share/cs3733/assign5/part3
  3. Test of extra credit
    1. Make a symbolic link called mylink that points to
      /usr/local/faculty/share/cs3733/assign5/part3
    2. Run the new remotesender in the directory containing mylink using just a port number as its command line argument.
    3. In a clean directory on a different machine, run remotereceiver with mylink as the directory.
    4. In this directory execute ls -l and save the result.
    5. Save the output generated by remotereceiver.
    6. In the copy of the removesender source, draw a box around the code that rejects requests containing .. or starting with "/".
Use this cover page.