
If the timer handler is called first, then you're done: initiate disconnection, etc. If the read handler is called first, you simply reset the timer (maybe cancel and then reset). I honestly don't know if you have to worry about a race condition (timer going off while handler for async_read is executing), or if a cancel / reschedule out of the async_read handler would preempt any other handlers. You might end up having to stick both the async_read and deadline_timer in the same strand; that would prohibit concurrent execution.
There is a good example: http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/example/timeouts/se rver.cpp and a good article: http://blog.think-async.com/2010/04/timeouts-by-analogy.html and a rather heavy example: http://sourceforge.net/projects/asio-samples/ (see project named echo_server). In general, you will need a state machine (or even few of them). Regards, Marat Abrarov.