boost asio resolver
asio 中的resolver一般用于将host等信息转化为socket信息,类似于getaddrinfo()
以下代码
boost::asio::io_service io; tcp::resolver resolver(io); tcp::resolver::query query(boost::asio::ip::host_name(), "80"); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); for (tcp::resolver::iterator iter; endpoint_iterator != iter; endpoint_iterator++) { std::cout << endpoint_iterator->endpoint() << std::endl; }
输出结果为:
[fe80::b085:5538:6305:667%13]:80 [fe80::c00c:b7bc:9c04:8ea6%18]:80 [fe80::144c:37dd:f5fc:e1a4%14]:80 10.3.30.91:80 192.168.1.150:80 192.168.128.1:80 [2001:0:9d38:953c:144c:37dd:f5fc:e1a4]:80
本博客注有“转”字样的为转载文章,其余为本人原创文章,转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232