private void loopUntilShutdown() throws Exception {
        while (true) {
            byte[] incoming = receive();
            MessageHandler handler = new MessageHandler(incoming);

            if (handler.isShutdownMessage())
                break;

            byte[] outgoing = handler.createResponseMessage();
            reply(outgoing);
        }
    }