class MarcFeedback extends Thread {

    @Override
    public void run() {
        try {
            final byte[] buffer = new byte[BUFFER_SIZE];
            final ByteArrayOutputStream out = new ByteArrayOutputStream();
            while (true) {
                final DatagramPacket packet =
                        new DatagramPacket(buffer, buffer.length);
                socket.receive(packet);
                out.write(buffer, 0, packet.getLength());
                final String response = out.toString();
                LOGGER.info("received from MARC: '" + response + "'");
                try {
                    final String id = parseId(response);
                    if (isEndOfSpeech(id)) {
                        output.playEnded(id);
                    }
                } catch (TransformerException e) {
                    LOGGER.warn("error parsing the response from MARC", e);
                } finally {
                    out.reset();
                }
            }
        } catch (IOException e) {
            LOGGER.error(e.getMessage(), e);
        } finally {
            if (socket != null) {
                socket.close();
            }
        }
    }

    public  MarcFeedback(final MarcSynthesizedOutput marcOutput,
            final int portNumber);

}