I'm making an (c++) application which is a websocket client and websocket server. To be able to do this, I'm using the library websocketpp. To make the application both a client and server, I want the endpoint1.run()
and endpoint2.listen(port)
to be multi-threaded. This is where something goes wrong.
Normally (single thread) I use: endpoint.listen(port);
which works.
To make it into a multi-thread I use:
boost::thread t(boost::bind(&server::listen, &endpoint, port));
sleep(1);
cout << "After thread! \n";
t.join();
However, I get the error:
main.cpp:116: error: no matching function for call to ‘bind(<unresolved overloaded function type>, websocketpp::server*, uint16_t&)’
server::listen
is an overloaded function, should I call it differently in bind?
Take a look at the boost documentation. There is a good example.
You need to resolve the ambiguity by your self.
For those who are still wondering how to implement this:
and after that call t.detach() or endpoint.stop() and t.join()