code: public boolean ping() throws IOException {
      try (Socket s = new Socket(hostName,port); OutputStream outs = s.getOutputStream()) {
        s.setSoTimeout(timeout);
        outs.write(asBytes("zPING\0"));
        outs.flush();
        byte[] b = new byte[PONG_REPLY_LEN];
        InputStream inputStream = s.getInputStream();
        int copyIndex = 0;
        int readResult;
        do {
          readResult = inputStream.read(b, copyIndex, Math.max(b.length - copyIndex, 0));
          copyIndex += readResult;
        } while (readResult > 0);
        return Arrays.equals(b, asBytes("PONG"));
      }
    }
docs: Run PING command to clamd to test it is responding.
  
  @return true if the server responded with proper ping reply.