Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hole punching with boost::asio

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);
like image 318
kavaliero Avatar asked Jun 18 '12 08:06

kavaliero


1 Answers

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

like image 91
mhall Avatar answered Oct 03 '22 17:10

mhall