// asion_simple.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <istream> #include <ostream> #include <string> #include <boost/asio.hpp> using boost::asio::ip::tcp; int main(int argc, char* argv[]) { try { if (argc != 3) { std::cout << "Usage: sync_client <server> <path>/n"; std::cout << "Example:/n"; std::cout << " sync_client www.boost.org /LICENSE_1_0.txt/n"; return 1; } // 定义一个 io_service boost::asio::io_service io_service; // Get a list of endpoints corresponding to the server name. // 定义一个域名解析器 tcp::resolver resolver(io_service); //定义一个查询query // tcp::resolver::query query("www.baidu.com", "http"); tcp::resolver::query query("127.0.0.1", "8000"); //解析query,获得节点 但是不明白为什么需要迭代器 //节点应该只有0个或者1个 tcp::resolver::iterator endpoint_iterator = resolver.resolve(qu