CSCI.4220 Network Programming
Spring, 2005
Programming Assignment 1

For this assignment you will write a simple ftp client and server which conforms to the following specification.

Hint: You might want to use the function sprintf to write digits to a string. The format string %07d write a seven char string with leading zeros.

Here is a sample run stream

  1. Server starts, listens on port 12345
  2. Client starts, connects to server (the request connection)
  3. Client listens on port 54321
  4. Client sends the string "54321" to server (6 bytes including terminal null char)
  5. Server connects to client on port 54321 (the data connection)
  6. Server acknowledges by sending "y0000000" on request connection
  7. Client sends dir to server on request connection (4 bytes)
  8. Server acknowledges by sending "y0000345" on the request connection
  9. Server sends the list of files on the data connection, a total of 345 bytes
  10. Client sends "get file1" on the request connection (10 bytes)
  11. Server acknowledges by sending "y0000678" on the request connection
  12. Server sends the contents of file1 (678 bytes) to the client on the data connection
  13. Client sends "dri" to the server on the request connection (bad command)
  14. Server acknowledges by sending "n0000000" on the request connection
  15. Client sends "quit" on the request connection (5 bytes)
  16. Server acknowledges by sending "y0000000" on the request connection.

Here are some constraints.

You must submit four separate source files, a unix client and server and a windows client and server.

When compiling the server on solaris, you should use the following command line
gcc -g -Wall -o server server.c -lnsl -lsocket -lphread
When compiling on FreeBSD, use this command line
gcc -g -Wall -o server server.c -pthread
When compiling on Windows in the .NET compiler, you have to link to the wsock32 library. To do this, choose Properties from the Project menu. The Properties page will appear. Choose Linker from the Configuration Properties, and then choose Input. The first line will read Additional Dependencies. Type wsock32.lib, and hit the OK button.

On Windows, to pass command line arguments from within the .NET development environment, choose Properties from the Project menu. Then choose debugging from the Configuration Properties. One of the lines will be labeled Command Arguments. Type in the arguments, delimited by spaces. Then hit the OK button.

The project is due at midnight on Tuesday, Feb. 8.