标签:
for (;;) { boost::array < char, 128 > buf; boost::system::error_code error; size_t len = socket.read_some(boost::asio::buffer(buf), boost::asio::assign_error(error)); //当服务器关闭连接时,boost::asio::ip::tcp::socket::read_some()会用boost::asio::error::eof标志完成, 这时我们应该退出读取循环了. if (error == boost::asio::error::eof) break; // Connection closed cleanly by peer. else if (error) throw error; // Some other error. std::cout.write(buf.data(), len); } //如果发生了什么异常我们同样会抛出它
BOOST中read_some和 boost::asio::error::eof(2)错误
标签:
原文地址:http://www.cnblogs.com/lovelylife/p/5536229.html