Hello, Am 14.06.2018 um 16:04 schrieb Álvaro Cebrián Juan via Boost-users:
From the documentation I can see that socket::receive() https://www.boost.org/doc/libs/1_58_0/doc/html/boost_asio/reference/basic_da... returns a variable of type "std::size_t", while the asynchronous version socket::async_receive() https://www.boost.org/doc/libs/1_58_0/doc/html/boost_asio/reference/basic_da... returns "void".
`socket::receive()` returns how much has been received and is similar to `recv()`. `socket::async_receive()` does not actually receive stuff -- it only tells your `asio::io_service` that as *it* receives something it shall pass that data on to your callback. Because `socket::async_receive()` is asynchronous (it only registers the socket <-> callback) and doesn't receive anything it can't return any meaningful size. This is one of the concepts of asynchronous development, I think refreshing your knowledge about that would be benefital.
This is also true for socket::send() https://www.boost.org/doc/libs/1_58_0/doc/html/boost_asio/reference/basic_da... and socket::async_send() https://www.boost.org/doc/libs/1_58_0/doc/html/boost_asio/reference/basic_da.... I was expecting that they would have the same return types, so there might be a good reason behind.
I would be grateful if someone can shed some light on this.
Thank you.
Álvaro
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users