On 29/11/2016 16:26, TONGARI J wrote:
The problem only happens if you have previous timeout. You can call socket.cancel() in the timeout branch.
I think the problem is that, if you don't call socket.cancel() on timeout, in the next round you're calling async_receive_from before the previous call completes, which is not allowed.
Note that even if you call cancel(), you still aren't allowed to immediately call async_receive_from() again. You need to cancel *and then* wait without timeout for the future to be ready before you can make another request. This should be fast (since you're just waiting for the cancellation to complete) but may not be zero time. (If you were using completion handlers rather than futures, this is equivalent to waiting for the handler to be called with a cancellation error before making another request.)