Fix iOS dead loop issue.

This commit is contained in:
Thomas Yuan 2015-11-13 14:27:13 -05:00
parent aa30d64432
commit b536cd4ab4
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);