Exercises

Exercise 1.

Create a simplified FTP (file transport) client and blocking server where the client can send or download text files from the server:

General use-cases
  1. ) Client connects to the server and sends a 'file listing' message
  2. ) Server sends back the list of the downloadable files
  3. ) Client lists the files and asks the user what action they want to take? Upload or download? ('u' or 'd')
  4. ) In both cases users must give the full file name with extension
  5. ) The client sends the selected file to the server (upload) or downloads the selected file from the server to a specific directory.
Server viewpoint
  1. ) After connecting, it reads the files from the /store subdirectory and sends the file names to the client after receiving the listing message.
  2. ) We are waiting for the client's 'u' or 'd' operation
  3. ) We get a filename from the client and if the action is 'd' (download), we read the file content and return its contents
  4. ) If the operation is 'u' (upload), we open a new file with the specified name and wait for the data to be written to the file.
Client viewpoint
  1. ) The client connects and waits for the list of files coming back and writes it to the console
  2. ) We ask for the „u” or „d” key
  3. ) Then we'll ask for the file-name as well.
  4. ) The client reads the files from the /files folder, or creates the downloaded file here
  5. ) If you press „d”, it creates /files/ and writes data from the server
  6. ) If you press „u”, /files/ is sent to the server

Exercise 2. Modify the blocking UDP code so that you can transfer a 'wired-in' name and existing binary image file larger than 2 kbytes and verify that it was successfully sent, eg. try to open the sent image by hand, in the Paint app.

Exercise 3. Try out the non-blocking starter Java code and examine/debug it.