php - Should I call dns_get_record() multiple times, or once with DNS_ANY? -


for php function dns_get_record(), using dns_any fetch records make more or less http (or whatever protocol) requests calling types individually?

// 1 request? or many requests (1 per each record type)? dns_get_record('example.com', dns_any);  vs  // 3 total requests? dns_get_record('example.com', dns_a); dns_get_record('example.com', dns_aaaa); dns_get_record('example.com', dns_mx);  

basically, minimize network requests if can, have no idea how dns_get_record() works under hood.

since documentation says dns_any doesn't return records, figured try calling types want individually more predictable results. doing makes 3 individual requests vs 1 request dns_any. true?

btw, dns_all or dns_a + dns_aaaa + dns_mx return false if of types null, can't way.

fetching info individually each type inefficient since involve multiple requests, whereas using dns_any parameter dns_get_record(), gets information in 1 request. dns_any parameter handy querying dns server info. particular parameter, may quite bit of info.

you can see if try using utility such "dig" @ linux commandline prompt domain gmail.com, follows:

dig gmail.com any

the output follows:

`;; question section: ;gmail.com.                     in       ;; answer section: gmail.com.              2386    in      mx      30 alt3.gmail-smtp-in.l.google.c                                                                              om. gmail.com.              2386    in      mx      40 alt4.gmail-smtp-in.l.google.c                                                                              om. gmail.com.              2386    in      mx      5 gmail-smtp-in.l.google.com. gmail.com.              2386    in      mx      10 alt1.gmail-smtp-in.l.google.c                                                                              om. gmail.com.              2386    in      mx      20 alt2.gmail-smtp-in.l.google.c                                                                              om. gmail.com.              85186   in      soa     ns1.google.com. dns-admin.google                                                                              .com. 2012061200 21600 3600 1209600 300 gmail.com.              81180   in      ns      ns3.google.com. gmail.com.              81180   in      ns      ns4.google.com. gmail.com.              81180   in      ns      ns1.google.com. gmail.com.              81180   in      ns      ns2.google.com.  ;; authority section: gmail.com.              81180   in      ns      ns2.google.com. gmail.com.              81180   in      ns      ns3.google.com. gmail.com.              81180   in      ns      ns4.google.com. gmail.com.              81180   in      ns      ns1.google.com.  ;; additional section: ns1.google.com.         223708  in            216.239.32.10 ns2.google.com.         223708  in            216.239.34.10 ns3.google.com.         223708  in            216.239.36.10 ns4.google.com.         223708  in            216.239.38.10  ;; query time: 4 msec [snip]  

php's dns_get_record() behaves dig utility, i.e. contacts dns server , performs query. parameter "dns_any" advantageous since gets @ once. since "dig" took 4 msec, assume dns_get_record() take approximately long or maybe longer. since dns_any parameter might yield more info 1 may require, 1 may, example, restrict query "mx" records using dns_mx function.

if you're curious php's internal source code function, here. internal source code written in c programming language.

if want know more how dns system works, when using php, see article php|architect entitled "email verification" (june 2008).


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -