Merge pull request #263 from thomas-yuan/dead_loop_on_ios

Fix iOS dead loop issue.
This commit is contained in:
Arvid Norberg 2015-11-14 12:55:53 -05:00
commit 64aba31e30
1 changed files with 10 additions and 0 deletions

View File

@ -311,6 +311,16 @@ void udp_socket::on_read(error_code const& ec, udp::socket* s)
if (err == boost::asio::error::would_block || err == boost::asio::error::try_again) break;
on_read_impl(ep, err, bytes_transferred);
// found on iOS, socket will be disconnected when app goes backgroud. try to reopen it.
if (err == boost::asio::error::not_connected || err == boost::asio::error::bad_descriptor)
{
ep = s->local_endpoint(err);
if (!err) {
bind(ep, err);
}
return;
}
}
call_drained_handler();
setup_read(s);