File Transfer

DUE MONDAY FEB 16th. -10% per workday after!!!

Your goal is to write a client and a server.

Server:
        Make a socket
        Wait for a connection
        Open a file 
        Until error or end-of-file
                read from socket
                write to file


Client
        Make a connection to the server
        Until error or end-of-file
                read from file
                write to connection

You get one point for every item above. This assignment is out of 10 points. If you can also send the filename from the client to the server, that's an extra credit point. You lose one point for every day after Mon Feb 11th.

If I were doing this assignment I would

  1. Start with your server from the last assignment.

  2. Add open-a-file

  3. Add read from the file and write to the socket

  4. Get a copy of your client from the last assignment.

  5. Edit it such that it just copies from the socket to the screen.

  6. Test this combination. You should see the file from the server on the client's screen.

  7. Add a client side read/write loop, copying the data from socket to file

  8. Test

  9. Celebrate

Checklist for the program

  1. Run the server with no arguments. It should not crash.

  2. Run the server with port 80. It cannot have port 80 unless you are root. It should warn and exit.

  3. Run the client without starting the server first. It should notice it did not connect to the server.

  4. Run the client with no arguments. It should not crash.

  5. Run the client with a misspelled hostname. It should notice that it did not connect.

  6. Run the client with the wrong port number. It should notice that it did not connect.

  7. If you can set the filename, set the filename to "/". You don't have permission to write to that. It should warn or something.

  8. While the client and server are connected, kill the server. The client should notice but not crash but maybe exit.