Boost 输出缓冲流

Boost 输出缓冲流,boost,tcp,buffer,cout,Boost,Tcp,Buffer,Cout,我正在尝试显示从tcp套接字接收的消息,该套接字以“\r\n\r\n”结尾 但是,即使服务器指示消息已成功传输,C++也会立即终止 void handle_read( const boost::system::error_code& error, size_t bytes_transferred) { std::istream response_stream(&response_); std::string incoming; std::s

我正在尝试显示从tcp套接字接收的消息,该套接字以“\r\n\r\n”结尾

但是,即使服务器指示消息已成功传输,C++也会立即终止

        void handle_read( const boost::system::error_code& error, size_t bytes_transferred)
{
    std::istream response_stream(&response_);
    std::string incoming;
    std::string res_time = make_daytime_string();
    while (std::getline(response_stream, incoming) && incoming != "\r")
         std::cout << incoming << std::endl;
    std::cout <<"message received on "<< res_time <<std::endl;
}
void handle\u read(const boost::system::error\u code&error,大小\u t字节\u传输)
{
std::istream响应流(&response);
std::字符串传入;
std::string res_time=make_days_string();
while(std::getline(响应流,传入)和传入!=“\r”)
std::cout

显然,我只需要解决套接字连接问题

如果在单线程io_服务上运行此服务,它很可能会失败,因为您在完成处理程序中(因此您正在阻止事件循环)。如果您将其设置为SSCCE,我们可以对其进行验证。并且可能会提出修复建议