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.
精彩评论