public void run() {
      try {
        listen(port);

        os.write(logN);
        os.write(recurFactor);
        os.write(logCutoff);
        os.write(capacity);
        os.write(dataSize);
        os.flush();

        //				System.out.println("\nlogN recurFactor  cutoff capacity dataSize");
        //				System.out.println(logN + " " + recurFactor + " " + cutoff
        //						+ " " + capacity + " " + dataSize);

        @SuppressWarnings("unchecked")
        CompEnv<Boolean> env = CompEnv.getEnv(Mode.COUNT, Party.Alice, this);
        LinearScanOram<Boolean> client = new LinearScanOram<Boolean>(env, N, dataSize);

        for (int i = 0; i < writeCount; ++i) {
          int element = i % N;

          Flag.sw.ands = 0;
          Boolean[] scData = env.inputOfAlice(Utils.fromInt(element, dataSize));
          os.flush();
          //					Flag.sw.startTotal();
          ((PMCompEnv) env).statistic.flush();
          client.write(client.lib.toSignals(element), scData);
          System.out.println(logN + "\t" + ((PMCompEnv) env).statistic.andGate);
          //					double t = Flag.sw.stopTotal();
          //					System.out.println(Flag.sw.ands + " " + t / 1000000000.0
          //							+ " " + Flag.sw.ands / t * 1000);
          //					Flag.sw.addCounter();
          //
          //					Runtime rt = Runtime.getRuntime();
          //					double usedMB = (rt.totalMemory() - rt.freeMemory()) / 1024.0 / 1024.0;
          //					System.out.println("mem: " + usedMB);
        }

        for (int i = 0; i < readCount; ++i) {
          int element = i % N;
          Boolean[] scb = client.read(client.lib.toSignals(element));
          boolean[] b = env.outputToAlice(scb);

          // Assert.assertTrue(Utils.toInt(b) == element);
          if (Utils.toInt(b) != element)
            System.out.println("inconsistent: " + element + " " + Utils.toInt(b));
        }

        os.flush();

        disconnect();
      } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
      }
    }
    public void run() {
      try {
        connect(host, port);

        int logN = is.read();
        int recurFactor = is.read();
        int logCutoff = is.read();
        int cutoff = 1 << logCutoff;
        int capacity = is.read();
        int dataSize = is.read();

        int N = 1 << logN;
        //				System.out
        //						.println("\nlogN recurFactor  cutoff capacity dataSize");
        //				System.out.println(logN + " " + recurFactor + " " + cutoff
        //						+ " " + capacity + " " + dataSize);

        @SuppressWarnings("unchecked")
        CompEnv<Boolean> env = CompEnv.getEnv(Mode.COUNT, Party.Bob, this);
        LinearScanOram<Boolean> server = new LinearScanOram<Boolean>(env, N, dataSize);

        for (int i = 0; i < writeCount; ++i) {
          int element = i % N;
          Boolean[] scData = server.env.inputOfAlice(new boolean[dataSize]);
          //					Flag.sw.startTotal();
          server.write(server.lib.toSignals(element), scData);
          //					 Flag.sw.stopTotal();
          //					 Flag.sw.addCounter();
          //					printStatistic();
        }

        int cnt = 0;
        for (int i = 0; i < readCount; ++i) {
          int element = i % N;
          Boolean[] scb = server.read(server.lib.toSignals(element));
          server.env.outputToAlice(scb);
          if (i % N == 0) System.out.println(cnt++);
        }

        disconnect();
      } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
      }
    }