private void handleReceivedByteBuffer(final byte[] bytes) {
    logger.atInfo().log("Received byte stream from socket...");

    try {
      final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      final Document match = builder.parse(new ByteArrayInputStream(bytes));
      final XPath xpath = XPathFactory.newInstance().newXPath();
      final DiffRequestMessage data = new DiffRequestMessage();
      final boolean flowGraphMatch =
          "flow_graph".equals(xpath.evaluate("/BinDiffMatch/@type", match));
      data.setMatchesDBPath(xpath.evaluate("/BinDiffMatch/Database/@path", match));
      data.setBinExportPath(xpath.evaluate("/BinDiffMatch/Primary/@path", match), ESide.PRIMARY);
      data.setFunctionAddress(
          Long.parseUnsignedLong(xpath.evaluate("/BinDiffMatch/Primary/@address", match)),
          ESide.PRIMARY);
      data.setBinExportPath(
          xpath.evaluate("/BinDiffMatch/Secondary/@path", match), ESide.SECONDARY);
      data.setFunctionAddress(
          Long.parseUnsignedLong(xpath.evaluate("/BinDiffMatch/Secondary/@address", match)),
          ESide.SECONDARY);
      if (flowGraphMatch) {
        controller.openFunctionDiffView(data);
      } else {
        controller.openCallGraphDiffView(data);
      }
    } catch (final ParserConfigurationException e) {
      // Should not happen as the XML support ships with the JRE.
      throw new RuntimeException(e);
    } catch (final IOException e) {
      handleError(e, "Error reading from socket: " + e.getMessage());
    } catch (final SAXException | XPathException e) {
      handleError(e, "Failed to parse data from socket: " + e.getMessage());
    }
  }
Socket handler that listens for commands to display flow graphs.
java/ui/src/main/java/com/google/security/zynamics/bindiff/socketserver/SocketServer.java