问题
I'm developing a tcp server in c++ using boost. I'd like process incoming data line by line and am looking for a socket.readLine method. However, I can only find a read_some() method. I don't what the definition on "some" is, but I don't think the string necessarily ends with a "\n".
So how can I implement socket.readLine() using boost?
回答1:
I assume you are using boost::asio. If so, there is a read_until() function that does what you want.
http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/read_until.html
回答2:
there is read_until
回答3:
Use boost::asio::read_until(..).
来源:https://stackoverflow.com/questions/7878361/boost-readline-for-tcp-client