How does getaddrinfo() do DNS lookup?

The short answer is “it asks the system“, which in turn knows how to do DNS lookups and which servers to use.

getaddrinfo() is documented by the getaddrinfo(3) manual page, which means it’s a C library function. It is also a POSIX function, so there is no canonical “source”; each standard C library of an operating system that conforms to POSIX will implement its own version. Either way the source to just that function is probably not too enlightening, since it would just call other functions and OS APIs, and you’d have to drill down pretty far to get to the actual DNS mechanism. You’d be better off reading documentation of the DNS protocol itself if you’re interested in how that works.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)