Hi Michael,
while(!timeout.elapsed()) { boost::system::error_code ec; boost::asio::socket_base::non_blocking_io command(true); socket.io_control(command); bytesRead = _socket->read_some(boost::asio::buffer(data, dataBufferSize), ec);
if(error&&boost::asio::error::would_block!=error) { //there is some other error the client has disconnected; } else { //I must have got some data or theres no data yet check bytesRead for that } boost::this_thread::sleep( boost::posix_time::milliseconds(100)); } No extra threads necessary.
Indeed. But the way I see it, you gotta be aware that each of you reads will take at least 100 mils, right? In my scenario this is not really affordable. Or am I missing something here? The first read will never have something ready in a reliable way, right? Nice try though... Stephan