[ASIO]what's the meaning of CompletionCondition in boost::asio::async_read?

dears, in function: void async_readfile:///F:/boost_1_40_0/doc/html/boost_asio/reference/async_read/overload2.h... (AsyncReadStream & s,const MutableBufferSequence & buffers, CompletionCondition completion_condition,ReadHandler handler); I am puzzled for the variant: "CompletionCondition completion_condition". take follow code as example: boost::asio::async_read(socket_,boost::asio::buffer(...),boost::asio::transfer_at_least(1),boost::bind(...)); Before I think it'll return if read 1 bit, but at fact it return until receive EOF or buffer is full. So why need this variant? It can return when receive EOF or buffer is full if there is no this varant, just like: boost::asio::async_read(socket_,boost::asio::buffer(...),boost::bind(...));

take follow code as example: boost::asio::async_read(socket_,boost::asio::buffer(...),boost::asio::transfer_at_least(1),boost::bind(...)); Before I think it'll return if read 1 bit, but at fact it return until receive EOF or buffer is full.
Your handler will be called only after *at least* 1 byte is read. It doesn't mean that when the handler is called, you get *exactly* 1 byte in the buffer, but *at least* 1 byte.
participants (2)
-
Igor R
-
zong jinliang