Reading a single byte with Asio :: read

Is it possible to read one byte through asio :: read?

I get one byte response and it seems useless 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;

Thank.

+3
source share
2 answers

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

And this is not wasteful. What bothers you that you are wasting?

+2
source

boost :: asio is implemented on top of the crowded Winsock implementation for TCP I / O on Windows. In such an implementation, there is no way around buffers, etc.

0
source

Source: https://habr.com/ru/post/1756580/


All Articles