使用boost::asio实现的打洞技术

7

我尝试使用打洞协议创建服务器客户端。 因此,我向我的服务器发送了客户端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);

你需要发布一个可编译的小例子,展示确切的问题。仅凭你发布的摘录很难理解问题所在。 - Nim
1个回答

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接