fileCommand - rsanchez-wsu/jfiles GitHub Wiki

Scope: public
Return: void

  • @param String file - the name of the file requested by the client
  • @param Socket sock - a Socket object with the active client connection

When the "FILE" command is input by the client, this method is called to request the filename specified in the parameter. The fileCommand method is the part of the program that actually communicates with the server by sending it the string "FILE" along with the file parameter. This in turn causes the server to take action and find the requested filename, and output it line by line to the client over the socket connection. The fileCommand method creates a new empty text file in the client directory in the form of "copy-file.txt" and writes the received lines to the file. It also receives a checksum from the server and compares it to one that was generated for the file on the client side.