Hi,
 
I am using ASIO to create a server. The clients sends command to the server, the server executes it in it and sends back the result to the client (here the client remotely controls the server). Lets assume that one command implementation at the server side contains only an infinite loop, as this wastes the server resource, the client need to "interrupt" or "terminate" the execution of the infinite loop in the server. Is there any mechanism available in ASIO to accomplish this?
 
What I am doing now is, this long job is created as a thread, collect the thread's id and store it in a container. Then this id is send to the client, if the client wants to interrupt the thread, it sends another command (STOP_THREAD ) with this thread id, the server looks for the thread running with this id, and interrupts it. At the end of  execution thread, the thread id has to be removed from the container (thread id,pointer to thread). But this makes it very complicated, and it is not working right.
 
So I am looking for a solution available with ASIO...
 
Please share your ideas...
 
Thanks,
  Lloyd
 


___________________
Happy New Year 2010