Hello All, Thanks for resolving my ASIO related issues so far, special thanks to Igor R. Now I am having a very strange problem. My program (based on chat server example in ASIO documentation) work fine on a simulator machine and have been tested thoroughly. But when I put it on another machine, it starts giving strange problems some seems to be random but I observed one of them very consistent. std::vectorboost::asio::const_buffer buffers; buffers.push_back(boost::asio::buffer(_outbound_header)); buffers.push_back(boost::asio::buffer(_outbound_message)); buffers.push_back(boost::asio::buffer(_outbound_data)); boost::asio::async_write(*_socket, buffers, boost::bind(&DJClient::handle_write, this, boost::asio::placeholders::error)); For the above code, handle_write is never called. I can see on the server side that the server has received the request and has also sent the response. But I do not receive the response in the client side. It seems something is going wrong with io_service but don't know what. The same code has worked on a different machine. Any help will be highly appreciated. Regards, Anil Agrawal Patrick Technology & Systems Phone: +61 2 8333-6340
boost::asio::async_write(*_socket, buffers, boost::bind(&DJClient::handle_write, this, boost::asio::placeholders::error)); For the above code, handle_write is never called. I can see on the server side that the server has received the request and has also sent the response. But I do not receive the response in the client side. It seems something is going wrong with io_service
If the handlers are not invoked, your io_serivce probably isn't running. Try to add a log message after io_service::run() call, so that you'll see when it exits. If your design needs io_service restart, don't forget to call io_servie::reset() before any subsequent run(). If you see that the io_service::run() doesn't exit, then maybe one of the handlers blocks the io_service queue (eg., due to some mutex lock or something like that).
If the handlers are not invoked, your io_serivce probably isn't running. Try to add a log message after io_service::run() call, so that you'll see when it exits. If your design needs io_service restart, don't forget to call io_servie::reset() before any subsequent run().
I second this recommendation. I once spent a long time trying to figure out a similar problem and when i stepped into io_service::run it returned immediately and i felt pretty stupid when i saw why. Zach
participants (3)
-
A.Agrawal@patrick.com.au
-
Igor R
-
Zachary Turner