2012-01-27 159 views
2

我想连接到由目标ip地址和端口号指定的服务器套接字。boost asio - 使用ip地址连接

boost :: asio :: connect似乎不允许使用它。我有ip目的地作为一个无符号整型值。

更新:我能够做

ba::ip::tcp::endpoint endpoint(ba::ip::address(ba::ip::address_v4(req.IpDst())), ntohs(req.Port())); 

但如何,我可以使用端点连接?

+0

看一看的构造basic_endpoint http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/ip__basic_endpoint/ basic_endpoint/overload2.html – mark 2012-01-27 22:10:34

+0

@mark感谢您指出,我刚刚发现我自己。但是,我如何使用连接端点?只有使用resolver迭代器才能看到它... – Ghita 2012-01-27 22:13:36

回答

4

它可以使用:

socket.connect(endpoint);