Hi Bill - without looking at your code in detail
(so I'm not sure where the bug is), you might want to consider having a single
thread running the io_service, and have the callbacks / completion handlers
forward any significant work through a wait queue to a thread pool. This
isolates all of the Asio interaction from the code doing the app work,
which is going to greatly simplify your thread safety and your Asio related
networking code. The networking code then does not have to deal with
multiple threads, strands, mutex locks, and OS level socket thread safety, and
the app code only has to mutex protect the data that is shared between multiple
threads.
There's many wait queue examples available, or I
can share one I adapted from an Anthony Williams (Boost Thread author)
example.
Make sure your completion handler lifetimes are
correct, which it looks like you've handled with
"shared_from_this".
Otherwise, as Igor already mentioned, you probably
have a socket that is already closed.
Cliff