In addition to what Nim answered, you also did the classical asio error. As documented here: http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/io_service/run_one/overload1.html "Subsequent calls to run(), run_one(), poll() or poll_one() will return immediately unless there is a prior call to reset()."
After your .run_one
you need to call m_ioservice.reset()
or it will never do any running again. It just returns instead of invoking any any async operations and thus m_lengthReceive
will not change after the first time.
do{
m_ioService.run_one();
m_ioService.reset();
}while(m_lengthReceive == 0);
This is the reason people normally do not use run_one()
but run()
and start a new async operation within the handler of the last one. In that case the run()
does not return and no reset()
is required.