Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] sync receive_from with timeout
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2009-03-04 11:05:16

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...


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at