I am trying to run the following code:
some_sock.async_connect(...);
boost::asio::deadline_timer t(ios, boost::posix_time::seconds(2));
while (t.expires_from_now() >= boost::posix_time::seconds(0))
{
ios.run_one();
if (condition) return;
}
The desired behavior is to return from run_one () after timer t expires (after 2 seconds). In fact, run_one () blocks until a SYN-ACK or RST is received. If the server does not respond, run_one () will block a much longer timeout than 2 seconds.
What should I do to wait a certain amount of time for a connection doing some work in the background?
Thank.
source
share