From: Max M. <ma...@kt...> - 2011-01-17 16:11:43
|
Hey everybody. I have a problem using the asynchronous server version of the cpp-netlib. As soon as I make a request a bad_cast exception is cast on the thread that ran .run(). I am making a request to "http://localhost:11200/proxy/?url=http://www.google.se", but all other requests seem to fail aswell. This is working fine for the synchronous version of the server. I am making this request from firefox. Also, I am using v0.8 of the library. Any ideas? Checking the documentation for using the async-server, it seems to be pretty identical to what I am doing. //asyncproxy.cpp #include <string> #include "asyncproxy.h" namespace proxy { void ASyncProxy::startProxy(std::string url, std::string port) { boost::network::utils::thread_pool thread_pool(2); http_server server(url, port, *this, thread_pool); server.run(); } ASyncProxy::ASyncProxy(void (*callback)(std::string)) { this->callback = callback; } void ASyncProxy::operator()(http_server::request const & req, http_server::connection_ptr connection) { connection->set_status(http_server::connection::ok); } } int main() { proxy::ASyncProxy prox(&writeQueue); prox.startProxy("localhost", 11200); } //asyncproxy.h #include <boost\network\protocol\http\server.hpp> #include <boost\network\utils\thread_pool.hpp> namespace proxy { struct ASyncProxy { typedef boost::network::http::async_server<ASyncProxy> http_server; public: void startProxy(std::string url, std::string port); ASyncProxy(void (*callback)(std::string)); void operator()(http_server::request const & req, http_server::connection_ptr connection); private: void (*callback)(std::string); }; } #endif |