/** * Query a specific server for one entry. * @param q The question section of the DNS query. * @param host The dns server host. * @return The response (or null on timeout/error). * @throws IOException On IOErrors. */ public DNSMessage query(Question q, String host) throws IOException { return query(q, host, 53); }
/** * Query the system nameservers for a single entry of the class IN * (which is used for MX, SRV, A, AAAA and most other RRs). * * @param name The DNS name to request. * @param type The DNS type to request (SRV, A, AAAA, ...). * @return The response (or null on timeout/error). */ public DNSMessage query(String name, TYPE type) { Question q = new Question(name, type, CLASS.IN); return query(q); }
/** * Query a nameserver for a single entry. * @param name The DNS name to request. * @param type The DNS type to request (SRV, A, AAAA, ...). * @param clazz The class of the request (usually IN for Internet). * @param host The DNS server host. * @return The response (or null on timeout / failure). * @throws IOException On IO Errors. */ public DNSMessage query(String name, TYPE type, CLASS clazz, String host) throws IOException { Question q = new Question(name, type, clazz); return query(q, host); }
/** * Query a nameserver for a single entry. * @param name The DNS name to request. * @param type The DNS type to request (SRV, A, AAAA, ...). * @param clazz The class of the request (usually IN for Internet). * @param host The DNS server host. * @param port The DNS server port. * @return The response (or null on timeout / failure). * @throws IOException On IO Errors. */ public DNSMessage query(String name, TYPE type, CLASS clazz, String host, int port) throws IOException { Question q = new Question(name, type, clazz); return query(q, host, port); }
/** * Query the system nameservers for a single entry of any class. * * This can be used to determine the name server version, if name * is version.bind, type is TYPE.TXT and clazz is CLASS.CH. * * @param name The DNS name to request. * @param type The DNS type to request (SRV, A, AAAA, ...). * @param clazz The class of the request (usually IN for Internet). * @return The response (or null on timeout/error). */ public DNSMessage query(String name, TYPE type, CLASS clazz) { Question q = new Question(name, type, clazz); return query(q); }
for (String dns : dnsServer) { try { message = query(q, dns); if (message == null) { continue;