async_read不停调用handle函数
#需要每次调用async_read清空buf缓冲区
string buf;
void on_read() {
buf.clear();
buf.resize(1024);//不加这两行async_read会一直读取,调用handle函数
async_read(sock_, buffer(buf),transfer_at_least(5), [=](boost::system::error_code er, size_t sz) {
if (er) {
cout << "on_read error" << endl;
return;
}
this->on_write();
this->on_read();
});
}