开发者

Reading single byte with Asio::read

Is it possible to read a single byte via asio::read?

I'm getting a single byte response and it seems wasteful to use the current buffering code:

        //Read the 1 byte reply
        char buffer[1];
        size_t bytesRead = asio::read(s, asio::buffer(buffer, 1));
        if(bytesRead < 1) return false;

Tha开发者_Python百科nks.


No, passing a buffer of a single byte is the only way.

Also it isn't wasteful. What is it that you're concerned about wasting?


boost::asio is implemented on top of Windows' overlapped I/O TCP Winsock implementation. There's no way around buffers, etc. in such an implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜