public void receiveResponse(byte[] data, int length) throws IOException {
        DNSInputStream dnsIn = new DNSInputStream(data, 0, length);
        int id = dnsIn.readShort();
        if (id != queryID) {
            throw new IOException("ID does not match request");
        }
        int flags = dnsIn.readShort();
        decodeFlags(flags);
        int numQueries = dnsIn.readShort();
        int numAnswers = dnsIn.readShort();
        int numAuthorities = dnsIn.readShort();
        int numAdditional = dnsIn.readShort();
        while (numQueries-- > 0) { // discard questions
            dnsIn.readDomainName();
            dnsIn.readShort();
            dnsIn.readShort();
        }
        try {
            while (numAnswers-- > 0) {
                answers.addElement(dnsIn.readRR());
            }
            while (numAuthorities-- > 0) {
                authorities.addElement(dnsIn.readRR());
            }
            while (numAdditional-- > 0) {
                additional.addElement(dnsIn.readRR());
            }
        } catch (EOFException ex) {
            if (!truncated) {
                throw ex;
            }
        }
    }