boost::asio 查询网址ip和端口
2014-07-31 00:56
351 查看
#include "stdafx.h" #include <string> #include <boost/asio.hpp> using namespace std; using namespace boost::asio; int _tmain(int argc, _TCHAR* argv[]) { io_service my_io_service; ip::tcp::resolver resolver(my_io_service);//create a resolver in order to resolve the name of host and query //the name of sercice and host,then converte them to one or more endpoints ip::tcp::resolver::query query("www.baidu.com", "http");//create a query ip::tcp::resolver::iterator iter = resolver.resolve(query); ip::tcp::resolver::iterator end; // end marker while (iter != end) { ip::tcp::endpoint endpoint = *iter++; std::cout << endpoint << std::endl; //display ip and port.the style of display is like 10.0.0.1:80 } return 0; }
this picture display the result
相关文章推荐
- 【Boost】boost库asio详解10——服务器端口复用
- 思科交换机根据MAC-IP信息查询具体的交换机端口
- boost::asio::ip::tcp实现网络通信的小例子
- boost asio 库中通过socket获得远端的endpoint的参数(ip, port)
- C#实现Ping功能|根据网址查询IP
- boost::asio::ip::tcp::socket is connected?(如何知道socket已经连接?)
- boost::asio::ip::tcp实现网络通信的小例子
- boost::asio::ip::tcp::resolver::query定义不正确导致boost::asio::ip::tcp::resolver的resolve抛出异常
- C#实现Ping功能|根据网址查询IP
- [No0000CB]如何在命令行(cmd)通过TCP/IP端口(port)查询所在的进程号(pid)或进程名称,并终止该进程
- boost::asio::ip::tcp::resolver的故事
- 查询当前数据库名、用户名、数据库服务器IP、端口、数据库版本信息。
- boost::asio::ip::tcp实现网络通信的小例子
- boost::asio::ip::tcp::resolver::query定义不正确导致boost::asio::ip::tcp::resolver的resolve抛出异常
- linux下测试某网址或IP端口能否访问
- boost::asio::ip::tcp::socket is connected?(如何知道socket已经连接?)
- 如何在命令行(cmd)通过TCP/IP端口(port)查询所在的进程号(pid)或进程名称,并终止该进程
- boost asio socket 端口复用
- boost::asio::ip::tcp实现网络通信的小例子
- boost::asio::ip::tcp实现网络通信的小例子