JFiles Server Main StepThrough old - rsanchez-wsu/jfiles GitHub Wiki

##main() The main method calls the JFilesServer Creation method with a value of the constant PORT (9786). In theory this would tell the new server where to listen for new contacts. Currently, the main build does not. The creation method uses the constant port instead of the value passed into it, which is the same unless the program is edited, and changing this value will not change the port.

##JFilesServer Creation method

  1. Start a new socket on the port (9786). The socket is stored in the socket variable which is local to this instance of JFilesServer. Note, that there can only be one instance of JFIlesServer since they all use the same socket.
  2. Run the CreateXml() method which prints some code to the console and doesn't do anything to affect the main program currently.
  3. Run the setup() method.

##setup()

  1. Looks in various for a server config file. In the current build no file exists in any of these places so the default values will be used.
  2. Log a "maximum number of threads" from the config file(default 10). There is no indication that this does anything outside the setup method and the number of possible clients appears to be 50.
  3. Run the start() method.

##start()

  1. Start a new thread that will run the run() method of JFIlesServer object.
  2. The initial thread will now halt.

##run()

  1. Begin waiting for new contacts, which will be handled by the addthread(Socket socket) method.