Is there a way in Boost::ASIO to know if async_read_some
wont return in a particular time period to call a function without closing the socket? Usually async_read_some()
wont return if there is no more data to be transfered to the buffer.
_socket->async_read_some(
boost::asio::buffer(this->reply, sizeof(this>reply)),
boost::bind(
&TCP_IP_Connection::dataProcess,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
);
async_read_some
always returns immediately.
If you're talking about the handler (callback), if you close the socket before it returns, then I think the handler gets called with asio::error::operation_aborted
. If you handle this scenario then maybe you don't need to worry about if you're connected or not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.