Is boost.asio function for receiving / sending bad?

Data can be read or written to a connected TCP socket using receive (), async_receive (), send (), or async_send (). However, since this can lead to a short write or read, applications typically use the following instead: read (), async_read (), write (), and async_write ().

I really don't understand that notes like read (), async_read (), write () and async_write () can also end with a short write or read, right?
Why are these functions not the same?
Should I use them at all?
Can someone clarify this remark for me?

+7
c ++ boost boost-asio
source share
2 answers

read , async_read , write and async_write are composed functions that call class functions several times until the requested number of bytes is requested. They are included in the library as a convenience. Otherwise, each developer will need to implement the same logic.

Class functions directly transfer the main functions of the OS, which are mainly described in the documentation: these functions can be returned before all bytes are transferred.

In most cases, you should use free (bundled) functions to transfer data.

+6
source share

First of all, you must understand the word "asynchronous", it just means "no need to wait." After calling asynchronous actions, the next action will be performed without waiting for an asynchronous action. While synchronous should wait until previous synchronous actions return. The following two samples from Boost.Asio would make sense: TCP Synchronous Day Server

(Unfortunately, reputation is not enough, the second example is easy to find, called "Asynchronous TCP Day Server")

-one
source share

All Articles