Boost logo

Boost Users :

Subject: Re: [Boost-users] asio tcp::resolver, service resolution
From: Andrew Holden (aholden_at_[hidden])
Date: 2011-08-25 11:52:52


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).


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net