Hole punching with boost::asio
Asked Answered
D

1

7

I tried to make a server client with hole-punching protocole . So I send to my server my client IP and client Port, And when a second User is connected the server send to both client the Ip and port of the other client . So when I have this i tried to establish a connection between my both client and I have an error with 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(): Service not found Aborted

here is my code

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);
Dulse answered 18/6, 2012 at 8:31 Comment(1)
You need to post a small example which is compilable which shows the exact problem. It's hard to fathom what the issue could be looking at the excerpts you've posted.Lathing
J
2

check the parameters to your query.

You are printing response[1] as the host address and response[2] as the port. But you are constructing your query object with response[0] as the host address and response[1] as the port/service.

I suspect that "Service not found Aborted" refers to your hostname not looking like a port number or service name.

See http://www.boost.org/doc/libs/1_50_0/doc/html/boost_asio/reference/ip__basic_resolver_query/basic_resolver_query/overload4.html

Jar answered 9/7, 2012 at 22:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.