Example #1
0
  static void listen() {
    if (doLogging == true) {
      // first we connect to the database first
      connectDb();
    }
    PacketSource reader = BuildSource.makePacketSource(source);

    if (reader == null) {
      System.out.println("Cannot connect to destination.");
      System.out.println("Did you forget to do network@ip:port? Destination maybe wrong or busy");
    }
    try {
      reader.open(PrintStreamMessenger.err);

      for (; ; ) {
        byte[] packet = reader.readPacket();
        if (doLogging == true) logPacket(packet);
        if (doDisplay == true) PrettyPrint.print(packet);
        System.out.println();
      }
    } catch (IOException e) {
      System.err.println("Error on " + reader.getName() + ": " + e);
    }
  }