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

View: New views
2 Messages — Rating Filter:   Alert me  

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

by zongjinliang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

dears,
in function:
       void async_read(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(...));
 


_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

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

by Igor R :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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.
_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users