直白點(diǎn)說,就是對(duì)getaddrinfo()這個(gè)函數(shù)的適配。抽象點(diǎn)說就是解析器。
細(xì)節(jié)如下:
boost::asio::ip::tcp::resolver resolver(asioService);
boost::asio::ip::tcp::resolver::query queryEndpoints(boost::asio::ip::host_name(),"80");
boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(queryEndpoints);
;
for(boost::asio::ip::tcp::resolver::iterator iterNull;
endpoint_iterator != iterNull;
endpoint_iterator++)
{
std::cout << endpoint_iterator->endpoint() << std::endl;
}
上面的代碼有這么幾個(gè)類型:
boost::asio::ip::tcp::resolver
boost::asio::ip::tcp::resolver::query
boost::asio::ip::tcp::resolver::iterator
resolver抽線的是getaddrinfo()動(dòng)作
boost::asio::ip::tcp::resolver::query抽象的是getaddrinfo()需要的參數(shù)
boost::asio::ip::tcp::resolver::iterator抽象的是getaddrinfo()的結(jié)果
這整個(gè)體系是抽象winsock sdk到stl思想