protected void doTask() throws Exception {
    while (stateCheck(STATECHECK_RUNNING)) {
      try {
        Socket client = server.accept();
        if (null != client) {
          ICShell clientShell = new ICShellSocket(client);

          LineProcessor processor;
          if (null != procNode) {
            processor =
                (ICShell.LineProcessor)
                    ICAppFrame.getComponent(procNode, ICShell.LineProcessor.class);
          } else {
            processor =
                new ICShellCmdProcessor(
                    (ICGenCommand) ICAppFrame.getComponent(APP_COMMANDS, ICGenCommand.class));
          }

          clientShell.setProcessor(processor);
          SocketAddress sa = client.getRemoteSocketAddress();
          clientShell.setName(getName() + " client connected from " + sa);
          clientShell.startShell();
        }
      } catch (SocketException ex) {
        // if the accept failed because stopRequested(), we should not throw exception
        if (stateCheck(STATECHECK_RUNNING)) {
          throw ex;
        }
      }
    }
  }
  protected boolean init() throws Exception {
    String ownerName = null;
    boolean portAvailable = true;

    try {
      Socket socket = new Socket("localhost", port);
      socket.setSoTimeout(soTimeout);

      ICShell testShell = new ICShellSocket(socket);

      ICShell.LineProcessor rp =
          new ICShell.LineProcessor(false) {
            public Object processLine(String line) throws Exception {
              return null;
            }
          };
      testShell.setProcessor(rp);
      testShell.startShell();
      // if it starts without problems, it means that the port is already served
      ownerName = testShell.getName();

      testShell.endShell();
      portAvailable = false;

    } catch (Exception ex) {
      // do nothing, this is the good way now
    }

    if (null != ownerName) {
      throw new Exception("The port " + port + " is owned by another application: " + ownerName);
    }

    if (!portAvailable) {
      throw new Exception("The port " + port + " is not available!");
    }
    server = new ServerSocket(port);

    return true;
  };