boost asio-使用IP地址连接 [英] boost asio - connect using an ip address

查看:181
本文介绍了boost asio-使用IP地址连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想连接到由目标IP地址和端口号指定的服务器套接字.

I want to connect to a server socket specified by a destination ip address and port number.

boost :: asio :: connect似乎不允许使用它.我将ip destination作为一个无符号的int值.

boost::asio::connect seems it does not allow to use this. I have ip destination as a unsigned int value.

更新:我能够做到

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

但是如何将端点与connect结合使用?

But how can I use endpoint with connect ?

推荐答案

可以使用:

socket.connect(endpoint);

这篇关于boost asio-使用IP地址连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆