public static void main(String[] args) throws IOException {
      final File socketFile =
          new File(new File(System.getProperty("java.io.tmpdir")), "junixsocket-test.sock");

      AFUNIXServerSocket server = AFUNIXServerSocket.newInstance();
      server.bind(new AFUNIXSocketAddress(socketFile));
      System.out.println("server: " + server);

      while (!Thread.interrupted()) {
        System.out.println("Waiting for connection...");
        Socket sock = server.accept();
        System.out.println("Connected: " + sock);

        InputStream is = sock.getInputStream();
        OutputStream os = sock.getOutputStream();

        System.out.println("Saying hello to client " + os);
        os.write("Hello, dear Client".getBytes());
        os.flush();

        byte[] buf = new byte[128];
        int read = is.read(buf);
        System.out.println("Client's response: " + new String(buf, 0, read));

        os.close();
        is.close();

        sock.close();
      }
    }
    public static void main(String[] args) throws IOException {
      final File socketFile =
          new File(new File(System.getProperty("java.io.tmpdir")), "junixsocket-test.sock");

      AFUNIXSocket sock = AFUNIXSocket.newInstance();
      try {
        sock.connect(new AFUNIXSocketAddress(socketFile));
      } catch (AFUNIXSocketException e) {
        System.out.println("Cannot connect to server. Have you started it?");
        System.out.flush();
        throw e;
      }
      System.out.println("Connected");

      InputStream is = sock.getInputStream();
      OutputStream os = sock.getOutputStream();

      byte[] buf = new byte[128];

      int read = is.read(buf);
      System.out.println("Server says: " + new String(buf, 0, read));

      System.out.println("Replying to server...");
      os.write("Hello Server".getBytes());
      os.flush();

      os.close();
      is.close();

      sock.close();

      System.out.println("End of communication.");
    }
  @BeforeClass
  public static void init() throws Exception {

    // these two lines are only needed for ldaps when not running inside the server,
    // because CustomTrustManager is not used when running in CLI
    //
    // these two lines are not needed for starttls
    System.setProperty("javax.net.ssl.trustStore", LC.mailboxd_truststore.value());
    System.setProperty("javax.net.ssl.trustStorePassword", LC.mailboxd_truststore_password.value());

    CliUtil.toolSetup();

    // connConfig.setLocalConfig();
    // TestLdap.TestConfig.useConfig(TestLdap.TestConfig.UBID);
    // TestLdap.TestConfig.useConfig(TestLdap.TestConfig.LEGACY);
  }