MCPcopy Create free account
hub / github.com/boostorg/asio / async_write_message

Function async_write_message

example/cpp14/operations/composed_1.cpp:32–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31template <typename CompletionToken>
32auto async_write_message(tcp::socket& socket,
33 const char* message, CompletionToken&& token)
34 // The return type of the initiating function is deduced from the combination
35 // of:
36 //
37 // - the CompletionToken type,
38 // - the completion handler signature, and
39 // - the asynchronous operation's initiation function object.
40 //
41 // When the completion token is a simple callback, the return type is void.
42 // However, when the completion token is boost::asio::yield_context (used for
43 // stackful coroutines) the return type would be std::size_t, and when the
44 // completion token is boost::asio::use_future it would be std::future<std::size_t>.
45 // When the completion token is boost::asio::deferred, the return type differs for
46 // each asynchronous operation.
47 //
48 // In C++14 we can omit the return type as it is automatically deduced from
49 // the return type of our underlying asynchronous operation.
50{
51 // When delegating to the underlying operation we must take care to perfectly
52 // forward the completion token. This ensures that our operation works
53 // correctly with move-only function objects as callbacks, as well as other
54 // completion token types.
55 return boost::asio::async_write(socket,
56 boost::asio::buffer(message, std::strlen(message)),
57 std::forward<CompletionToken>(token));
58}
59
60//------------------------------------------------------------------------------
61

Callers 3

test_callbackFunction · 0.70
test_deferredFunction · 0.70
test_futureFunction · 0.70

Calls 2

async_writeFunction · 0.85
bufferFunction · 0.85

Tested by 3

test_callbackFunction · 0.56
test_deferredFunction · 0.56
test_futureFunction · 0.56