打孔与助推::asio
Hole punching with boost::asio
本文关键字:asio 更新时间:2023-10-16
我试图用打孔协议制作一个服务器客户端。所以我将我的客户端 IP 和客户端端口发送到我的服务器,当第二个用户连接时,服务器向两个客户端发送另一个客户端的 IP 和端口。所以当我有这个时,我试图在我的两个客户端之间建立连接,并且我在 boost::asio 时出错
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
what(): 未找到服务中止
这是我的代码
std::vector<std::string> response;
response = split(reply, ':');
std::cout << "name : " << response[0] << std::endl;
std::cout << "adresse : " << response[1] << std::endl;
std::cout << "port : " << response[2] << std::endl;
udp::resolver::query query(udp::v4(), response[0], response[1]);
std::cout << "resolved - - - -" << std::endl;
struct client *cl = new struct client();
cl->endpoint_iterator = resolver.resolve(query);
// It Crash HERE
cl->sender_endpoint = *endpoint_iterator;
cl->name = response[0];
_clients.push_back(cl);
检查查询的参数。
您正在打印响应 [1] 作为主机地址,将响应 [2] 打印为端口。但是您正在构造查询对象,其中响应 [0] 作为主机地址,响应 [1] 作为端口/服务。
我怀疑"找不到服务已中止"是指您的主机名看起来不像端口号或服务名称。
请参阅 http://www.boost.org/doc/libs/1_50_0/doc/html/boost_asio/reference/ip__basic_resolver_query/basic_resolver_query/overload4.html
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- 提升 ASIO 无法识别计时器对象
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- boost::asio::steady_timer()与sleep()我应该使用哪一个
- boost::asio如何生成多个协同程序,然后加入它们
- 缓慢提升ASIO
- 从 Boost ASIO 获取 epoll 描述符 io_service对象
- 如何在 Boost.Asio 中使用 Zero-copy sendmsg/receive
- C++ Boost::asio串行通信与Arduino无法写入
- 如何使用 Boost Asio 在 Android 上获取我的本地 udp IP 地址?
- 提升 Asio TCP 服务器 处理多个客户端
- boost::asio UDP 广播客户端仅接收"fast"数据包
- 提升 ASIO - io_service 不要等待连接到线程
- 执行时使用 boost::asio::d eadline_timer 时出错
- Boost.Asio/OpenSSL HTTPS GET certificate trouble
- C++ boost::asio::ip::tcp::acceptor 有时不接受连接器?
- boost::asio data owning `ConstBufferSequence`
- 如何替换此示例代码片段中已弃用的handler_type_t或 boost::asio::handler_type?
- 将 boost 序列化对象的 asio::streambuf 表示转换为 Beast 的 DynamicBody req.body()
- 如何将boost::asio::d eadline_timer 与Qt一起使用?