Beispiel #1
0
  public void run() {
    logger.info("Started GSN Controller on port " + gsnControllerPort);
    while (true) {
      try {
        Socket socket = mySocket.accept();
        logger.debug("Opened connection on control socket.");
        socket.setSoTimeout(GSN_CONTROL_READ_TIMEOUT);

        // Only connections from localhost are allowed
        if (ValidityTools.isLocalhost(socket.getInetAddress().getHostAddress()) == false) {
          try {
            logger.warn(
                "Connection request from IP address >"
                    + socket.getInetAddress().getHostAddress()
                    + "< was denied.");
            socket.close();
          } catch (IOException ioe) {
            // do nothing
          }
          continue;
        }
        new StopManager().start();
      } catch (SocketTimeoutException e) {
        logger.debug("Connection timed out. Message was: " + e.getMessage());
      } catch (IOException e) {
        logger.warn("Error while accepting control connection: " + e.getMessage());
      }
    }
  }