boost: readline for tcp client

拟墨画扇 提交于 2021-01-28 04:20:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!