/**
  * Called whenever the program ETAMonitor attempts to make a connection to this instance of ETA.
  * This should always be under the local IP and the last 30bytes are extracted and checked against
  * the database and checked to see if this is a valid token.
  *
  * <p>A connection should be established any time a job gets started on a machine. The idea of
  * this is to provide a gateway to the job that is running in case the user wants to send data to
  * job and it tells ETA that the job started on which machine and when it finishes. It also gets
  * the exit code to check if the job finished properly.
  *
  * @param client The {@link Socket} that the {@link ServerSocket} created when this connection was
  *     established.
  * @param info The first 31 bytes that was sent to this socket
  */
 private void etaMonitorConnected(Socket client, byte[] info) {
   System.out.println("monitor connected with info--" + new String(info));
   User user = getUserForToken(info);
   if (user == null) {
     try {
       client.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
     return;
   }
   String jobNumber = "";
   char letter;
   try {
     System.out.println("reading job for user " + user.getName());
     while ((letter = (char) client.getInputStream().read()) != '\n' && letter > -1) {
       jobNumber += letter;
     }
     System.out.println("job #" + jobNumber);
   } catch (IOException e) {
     return;
   }
   final int job = Integer.parseInt(jobNumber);
   RMIConnection con =
       new RMIConnection(
           client,
           this,
           false,
           new ConnectionListener() {
             @Override
             public void connectionLost() {
               monitorServices.remove(job);
             }
           });
   monitorServices.put(job, (RemoteMonitorService) con.getService(RemoteMonitorService.class));
 }