Reputation: 1594
I'm writing a program that transfer large data over network and I'm using boost asio iostream to do it.
here's my code :
boost::asio::ip::tcp::iostream s;
s.connect("localhost","4000");
string ss;
getline(s,ss);
but getline does not read a complete line when output is more than 4096 charachters and it break it into two messages.
what is the right way to read a single line when input is large?
Upvotes: 1
Views: 322
Reputation: 392833
I'm not reproducing this with
Did you check there are no linefeeds in the input?
If I feed it a continues stream of input, I do not detect such issues. E.g. with netcat, Live On Coliru
for a in {1..1024}; do echo -n 0123456789; done | nc -l 6767&
This sends 10k of data without linefeeds
./a.out | wc
This counts lines, words and characters returned by our code:
0 1 10240
for reference
#include <boost/asio.hpp>
#include <iostream>
int main() {
boost::asio::ip::tcp::iostream socket("127.0.0.1","6767");
std::string as_read;
std::getline(socket,as_read);
std::cout << as_read;
}
Upvotes: 1