DNSRecord rec = (DNSRecord)e.nextElement(); if (!rec.isExpired(now)) { try { out.addAnswer(rec, now); } catch (IOException ee) { break; }
final ServiceInfo info = (ServiceInfo)e.nextElement(); try { out.addAnswer(new DNSRecord.Pointer(info.type, DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, info.getQualifiedName()), now); } catch (IOException ee) { break;
        public void run() {            try {                if (state == DNSState.ANNOUNCED) {                    if (count++ < 3) {                        long now = System.currentTimeMillis();                        DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);                        out.addQuestion(new DNSQuestion(type, DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN));                        for (Enumeration e = services.elements() ; e.hasMoreElements() ;) {                            DNSRecord rec = (DNSRecord)e.nextElement();                            if (!rec.isExpired(now)) {                                try {                                    out.addAnswer(rec, now);                                } catch (IOException ee) {                                    break;                                }                            }                        }                        send(out);                    } else {                        // After three queries, we can quit.                        cancel();                    };                } else if (state == DNSState.CANCELED) {                    cancel();                }            } catch (Throwable e) {                e.printStackTrace();                close();            }        }