Synchronous read/write operations

    Please notice the buffer types of send/receive are , and we can use boost::asio::buffer function to construct related types.

    There is the server program which waits receiving greeting from client:

    Server outputs following:

    If we don’t bother to check the middle state (partial bytes are sent successfully), and only care whether all bytes are sent successfully or not, we can use boost::asio::write which actually uses under the hood. Correspondingly, it is not hard to guess what boost::asio::readdoes.