Why is port number given when doing a DNS lookup?
03:51 14 May 2024

In ASIO C++ networking library you can resolve an address by creating a query object, whose constructor takes (optionally whether it's ip4 or ip6), a host argument and a service argument. The host is the name of the site you want to resolve to an IP number, and the service (I'm guessing) is the port number.
So this does a DNS lookup/request, but my understanding is that DNS queries are for looking up associations between names and IP numbers, I don't see how the port figures into this at all.

asio::ip::tcp::resolver::query query{"www.google.com", "80"};

Adding further to my befuddlement, there's a query constructor that takes just the service. The comment gives a little explanation:

This constructor is typically used to perform name resolution for local service binding

I don't understand, I thought DNS lookups were for strictly for (name -> IP number) mappings. If I resolve a name with port 109 and then the same name with port 400, do I get back the same IP numbers?

c++ network-programming boost-asio