Maybe the thread that calls async_read exits before the relevant completion handler is invoked?
By the way, using threads in the way you described in asio-based program is usually a bad idea. The whole point of using async i/o is to avoid such an "explicit" multithreading -- usually one spawns multiple threads to scale for multiple CPUs only. http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/examples.html#boost... http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/examples.html#boost...
Yes, you are right, the thread is exiting before the async_read_some. I would like to let you know why I am using threads. This is a server application. The client can give any command, and the server will execute it. Some commands may take much longer time. In this kind of situations, the client may want to STOP the execution of that long job. With the help of threading I am able to do this with the help "Interruption points and interrupts". The server will receive a "STOP command with the thread ID" from the client, So the server can interrupt the thread and stop the job. Is there a better way to implement this? I would be very happy to know that, than using this dirty way I am using now... Thanks a lot, Lloyd ______________________________________ Scanned and protected by Email scanner