Tutorial :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;  



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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »