asio::read() 需要很长时间,asio::write 没问题

asio::read() takes really long time, no proble with asio::write

我正在编写简单的同步 SMTP 和 POP3 客户端。问题在于读取服务器响应。它被正确读取,虽然它需要很长时间,比如一分钟。我查看了与 wireshark 的通信,我立即得到响应,但不知何故这条线正在节流(调试器检查)

boost::asio::read(socket, receiveBuffer, boost::asio::transfer_all(), error);

我是不是做错了什么?你知道有什么解决办法吗?

transfer_all for streambuf returns in two cases: 64k bytes of data was read (it is default value for reading data in single operation), or error occured, for example the second side closed connection, and as a result in this case you have some read data with EOF as the error. Your call of write works, because write takes some buffer and has its length, so it knows how many bytes must be sent. If you don't know how much data has to be read, use read_until, read until \r\n sequence appears in coming data.

@rafix07