public Canceler(ServiceInfo info, Object lock) { this.infos = new ServiceInfo[]{info}; this.lock = lock; addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }
/** * For debugging only. */ public String toString() { return toString("question", null); } }
/** * Add a listener for a question. The listener will receive updates * of answers to the question as they arrive, or from the cache if they * are already available. */ void addListener(DNSListener listener, DNSQuestion question) { long now = System.currentTimeMillis(); // add the new listener synchronized (this) { listeners.add(listener); } // report existing matched records if (question != null) { for (DNSCache.CacheNode i = cache.find(question.name); i != null; i = i.next()) { DNSRecord c = (DNSRecord) i.getValue(); if (question.answeredBy(c) && !c.isExpired(now)) { listener.updateRecord(this, now, c); } } } }
public ServiceInfoResolver(ServiceInfo info) { this.info = info; info.dns = JmDNS.this; addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }
out.addQuestion(new DNSQuestion("_services._mdns._udp.local.", DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN)); for (Iterator iterator = serviceTypes.values().iterator(); iterator.hasNext();)
long now = System.currentTimeMillis(); DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY); out.addQuestion(new DNSQuestion(type, DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN)); for (Iterator s = services.values().iterator(); s.hasNext();)
out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN)); out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN)); if (info.server != null) out.addQuestion(new DNSQuestion(info.server, DNSConstants.TYPE_A, DNSConstants.CLASS_IN));
for (int i = 0; i < numQuestions; i++) DNSQuestion question = new DNSQuestion(readName(), readUnsignedShort(), readUnsignedShort()); questions.add(question);
out.addQuestion(new DNSQuestion(localHost.getName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); DNSRecord answer = localHost.getDNS4AddressRecord(); if (answer != null) out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN));