Note that getaddrinfo() only calls DNS if nsswitch.conf defines it. The files entry reads, directly, from /etc/hosts.
Basically, the "name service switch" functions (NSS) look at /etc/nsswitch.conf and then may dynamically load "libnss" routines. So, for example, you might have /lib/x86_64-linux-gnu/libnss_files.so.2, which is the library loaded when files is mentioned in nsswitch.conf.
For hosts, the nsswitch.conf line may read something like
hosts: files dns
This will tell the name service resolver to load the "nss_files" library (which will look in /etc/hosts) and if that fails, load the "nss_dns" library. It's that library that calls out to a DNS server.
For services, the nsswitch.conf line may read something like
services: files ldap
This will load the "nss_files" library (which will look in /etc/services), and if that fails then load the "nss_ldap" library.
There are various different backends (files, db, ldap, nis, compat, dns...) and they determine how names are resolved.
For an inet entry such as
service time
{
...
}
the time value is looked up in the NSS map for services. If files is used in nsswitch.conf then it will see a line
time 37/tcp timserver
which tells inetd to bind to TCP port 37.