gethostbyname uses /etc/nsswitch.conf to determine how host names should be resolved. The document describes /etc/hosts and DNS, but there can be more.
On modern systems, it is likely that multicast DNS is performed to resolve local names before going to DNS.
I actually pointed this out in my Google interview and the interviewer instructed me to skip Name Service Switch part.
On modern systems, it is likely that multicast DNS is performed to resolve local names before going to DNS.
I actually pointed this out in my Google interview and the interviewer instructed me to skip Name Service Switch part.