boost:tcp客户端的readline [英] boost: readline for tcp client

查看:72
本文介绍了boost:tcp客户端的readline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Boost开发C ++中的TCP服务器.我想逐行处理传入的数据,并正在寻找一个socket.readLine方法.但是,我只能找到一个read_some()方法.我对"some"的定义不是什么,但我认为字符串不一定以"\ n"结尾.

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".

那么如何使用boost实现socket.readLine()?

So how can I implement socket.readLine() using boost?

推荐答案

我假设您正在使用boost :: asio.如果是这样,那么有一个read_until()函数可以满足您的需求.

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

这篇关于boost:tcp客户端的readline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆