asio tcp::resolver, service resolution

Hi, In documentation I saw that using tcp::resolver::query constructor it is possible to resolve domain.name as well as service name, as shown in the following code fragment. boost::asio::io_service ios; boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::query query("mydomain.com","myservice"); Here 'myservice' is not a well known service (port number). For resolving 'myservice' where should I add the port number? in my domain name server's (BIND) /etc/services file or in my local systems services file? Or is it 'really' possible to resolve a service name? Thanks, Lloyd

In documentation I saw that using tcp::resolver::query constructor it is possible to resolve domain.name as well as service name, as shown in
On Thursday, August 25, 2011 11:21 AM, Lloyd wrote: the
following code fragment.
boost::asio::io_service ios; boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::query query("mydomain.com","myservice");
Here 'myservice' is not a well known service (port number).
For resolving 'myservice' where should I add the port number? in my domain name server's (BIND) /etc/services file or in my local systems services file?
Or is it 'really' possible to resolve a service name?
The easiest method is to include the service port number as a string. For example, if you're listening on port 12345, your query would be: boost::asio::ip::tcp::resolver::query query("mydomain.com","12345"); If you hope your program will be widely distributed, then it might to worth your while to register your port name with IANA and wait for your and your clients' OS vender to update the "services" file (/etc/services or c:\windows\system32\drivers\etc\sevices).

So the port resolution is not as easy as domain name resolution
Why the DNS protocol can't be extended to resolve services also? So
many people must have faced this issue, and why didn't thay think in
this way? Is there any technical barrier?
Thanks a lot,
Lloyd
On Thu, Aug 25, 2011 at 9:22 PM, Andrew Holden
In documentation I saw that using tcp::resolver::query constructor it is possible to resolve domain.name as well as service name, as shown in
On Thursday, August 25, 2011 11:21 AM, Lloyd wrote: the
following code fragment.
boost::asio::io_service ios; boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::query query("mydomain.com","myservice");
Here 'myservice' is not a well known service (port number).
For resolving 'myservice' where should I add the port number? in my domain name server's (BIND) /etc/services file or in my local systems services file?
Or is it 'really' possible to resolve a service name?
The easiest method is to include the service port number as a string. For example, if you're listening on port 12345, your query would be:
boost::asio::ip::tcp::resolver::query query("mydomain.com","12345");
If you hope your program will be widely distributed, then it might to worth your while to register your port name with IANA and wait for your and your clients' OS vender to update the "services" file (/etc/services or c:\windows\system32\drivers\etc\sevices). _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Thursday, August 25, 2011 11:50 PM, Lloyd wrote:
Top post moved to bottom. Please don't top post.
On Thu, Aug 25, 2011 at 9:22 PM, Andrew Holden
wrote: On Thursday, August 25, 2011 11:21 AM, Lloyd wrote:
In documentation I saw that using tcp::resolver::query constructor it is possible to resolve domain.name as well as service name, as shown in the following code fragment.
boost::asio::io_service ios; boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::query query("mydomain.com","myservice");
Here 'myservice' is not a well known service (port number).
For resolving 'myservice' where should I add the port number? In my domain name server's (BIND) /etc/services file or in my local systems services file?
Or is it 'really' possible to resolve a service name?
The easiest method is to include the service port number as a string. For example, if you're listening on port 12345, your query would be:
boost::asio::ip::tcp::resolver::query query("mydomain.com","12345");
If you hope your program will be widely distributed, then it might to
worth your while to register your port name with IANA and wait for your and your clients' OS vender to update the "services" file (/etc/services or c:\windows\system32\drivers\etc\sevices).
So the port resolution is not as easy as domain name resolution
Why the DNS protocol can't be extended to resolve services also? So many people must have faced this issue, and why didn't thay think in this way? Is there any technical barrier?
Thanks a lot, Lloyd
I did some searching, and it seems that RFC 2782 defines a "SRV" DNS record for that purpose. I'm not sure how you would access these records in asio, though. Perhaps someone else knows more than I.

On Thu, Aug 25, 2011 at 10:49 PM, Lloyd
Why the DNS protocol can't be extended to resolve services also? So many people must have faced this issue, and why didn't thay think in this way? Is there any technical barrier?
only well-known service names can be reliably resolved via name; DNS doesn't address this because DNS was conceived to deal with domain name-to-IP address resolution. As someone else mentioned, there is a SRV record type in DNS that was intended to function similar to what you're after, but I do not believe that the value of the SRV records were standardize or that they were even intended to be only port names. If memory recalls correctly, the idea was to be able to search for a service within a subdomain. SRV never got much widespread use for whatever reason, and its proposed functionality may be largely subsumed and overshadowed by the much better specified and much more widely-deployed zeroconf protocol, two implementations of which are Bonjour (from Apple) and Avahi (on linux). The answer to your original issue of how to get the port number for your own service is to simply embed the default port number in your code, allow the user to specify a different port from a command line/config file, and allow specification of the port by name or by number. That's pretty much how it's been done for the last 20+ years. -cj
participants (3)
-
Andrew Holden
-
Chris Cleeland
-
Lloyd