有例如HTTP客戶端在http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/http/client/async_client.cpp 請幫我變化最大緩衝區大小像下面的代碼解釋(它是從庫中下載的例子,而不是從網站):Boost.Asio的 - 設置最大讀取流大小
void handle_write_request(const boost::system::error_code& err)
{
if (!err)
{
// Read the response status line. The response_ streambuf will
// automatically grow to accommodate the entire line. The growth may be
// limited by <b>passing a maximum size to the streambuf constructor</b>.
boost::asio::async_read_until(socket_, response_, "\r\n",
boost::bind(&client::handle_read_status_line, this,
boost::asio::placeholders::error));
}
else
{
std::cout << "Error: " << err.message() << "\n";
}
}
而這裏的響應緩衝區的構造函數:
boost::asio::streambuf response_;
但是編譯器說,下面的代碼是無效的:
boost::asio::streambuf response_(
1024
);
似乎默認緩衝區是512
字節大小,我需要更大的尺寸。
忘記我的512字節限制,我錯了。 – soulmare 2010-11-04 08:07:48
似乎response_變量根本沒有初始化,只是聲明和使用? – soulmare 2010-11-04 08:11:03
@soulmare:'response_'它的默認初始化 – 2010-11-04 08:28:52