protected void startListener() {
        for (PcapHandle handle : openHandles.values()) {
            PacketListener listener = createListener();
            Thread thread = new Thread(() -> {
                try {
                    handle.loop(-1, listener);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                } catch (PcapNativeException | NotOpenException e) {
                    logger.error("Got error handling raw socket", e);
                }
            });
            thread.setDaemon(true);
            thread.setName("RawSocket handler " + handle.getFilteringExpression());
            thread.start();
            // TODO: This might be leaking the thread after finishing.
        }
    }
This code is borrowed and stripped down from the Profinet driver
plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/discovery/ProfinetChannel.java