Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost::asio
From: Benedetto Proietti (bproietti_at_[hidden])
Date: 2011-06-02 12:39:37

From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Ram Sundar
Sent: Thursday, June 02, 2011 9:27 AM
To: boost-users_at_[hidden]
Subject: [Boost-users] Using boost::asio

    I am trying to use boost::asio for a project where we currently use ACE. The way it currently works, the data that is passed between the server and client is preceded by a header with the data length. Currently with ACE when data is ready to be read at the socket, the handler function is invoked, and we invoke a ioctl with FIONREAD to read the number of bytes ready to be read and then allocate a buffer of that length to read the data. The reason we do this way is because the data may be sent in chunks. Internally we keep track of how much data we have received etc. I am at a loss to know how to do this using boost::asio. All the read methods expect a buffer where data will be read and it also needs the size of the buffer. Is there a way we get notified when data is ready to be read, and do similar operation. ie read the number of bytes available to read and then allocate buffers to read the data? Are there any other methods to accomplish the same?


Hi Ram.
We have a similar situation (fixed size header + variable length body following). We happily use boost::asio with a very big buffer that can hold the biggest possible message.
We accumulate bytes, check the headers, and eventually process the body.
Can't you just use a big buffer and do the rest as you're doing now?


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