Boost logo

Boost Users :

Subject: Re: [Boost-users] std::future::wait_for() not working in Boost UDP socket async receive operation
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-11-28 23:01:28

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.)

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at