    private static void connectAgents(int type, List agents) {
        for (int i = 0;  i < m_num[type];  i ++)
          try {
                agents.add(connectAgent(type, isTCP));

            } catch (Error e) {
                String reason = e.getMessage();
                if ( (reason.regionMatches(true, 0, REASON_OF_KA_CONNECT_ERROR, 0,
                                           REASON_OF_KA_CONNECT_ERROR.length())
                      || reason.regionMatches(true, 0, REASON_OF_KA_CONNECT_ERROR2, 0,
                                           REASON_OF_KA_CONNECT_ERROR2.length())
                      )
                    && m_num[type] == Integer.MAX_VALUE)
                  break;
                System.err.println("connection failed.\n"
                                   + "    Reason: \"" + reason + "\"");
                System.exit(1);
            }
    }
