How can I read if there is some data in a buffer of boost::asio::socket? The check should block the execution of the program till a timeout is reached. I found out that it is possible to use the function
boost::asio::socket_base::bytes_readable
but is seems to be a non-blocking action that runs without checking any timeout. I don't want to use async_read but directly read the socket if there is some data to read
one easy way to block the execution of the program waiting for some bytes in the socket is to put the function in a while cycle that monitors the elapsed time. Here below a simple solution that will: