Boost logo

Boost :

Subject: [boost] [asio] boost::asio::read with empty input vector leads to an infinite loop
From: Michael Kochetkov (michael.kv_at_[hidden])
Date: 2012-07-12 16:20:34

In the code bellow I have forgotten to set the input vector (request) size.
Is the code really supposed to react as an infinite loop (no errors, length
is always 0, boost::asio::read returns immediately) or such behavior is a

        for (;;) {
                std::vector<uint8_t> request;
                boost::system::error_code error;
                size_t length = boost::asio::read(sock,
boost::asio::buffer(request), error);
                if (error == boost::asio::error::eof)
                else if (error)
                        throw my_exception(L"Socket error");

Thank you in advance,

Michael Kochetkov

Boost list run by bdawes at, gregod at, cpdaniel at, john at