In our application, we set the termination condition, and then use self-connection with the port that is listening to the stream, so it wakes up, notices the termination condition and exits.
You can also check the implementation of boost - if they do only normal reading on the socket (i.e. they do not use WaitForMultipleObjects inside themselves), then you can probably conclude that there is nothing to simply and cleanly unlock the thread. If they are waiting at several sites (or at the termination port), you can dig around to find out if the ability to wake up the blocking stream from the outside is available.
Finally, you can kill the thread, but you will need to go beyond boost to do this, and understand the consequences, such as a freeze or resource leak. If you conclude, this may not bother, depending on what else this thread is doing.
BeeOnRope
source share