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

Method write_line

example/cpp11/timeouts/blocking_tcp_client.cpp:94–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 }
93
94 void write_line(const std::string& line,
95 std::chrono::steady_clock::duration timeout)
96 {
97 std::string data = line + "\n";
98
99 // Start the asynchronous operation itself. The lambda that is used as a
100 // callback will update the error variable when the operation completes.
101 // The blocking_udp_client.cpp example shows how you can use std::bind
102 // rather than a lambda.
103 boost::system::error_code error;
104 boost::asio::async_write(socket_, boost::asio::buffer(data),
105 [&](const boost::system::error_code& result_error,
106 std::size_t /*result_n*/)
107 {
108 error = result_error;
109 });
110
111 // Run the operation until it completes, or until the timeout.
112 run(timeout);
113
114 // Determine whether the read completed successfully.
115 if (error)
116 throw boost::system::system_error(error);
117 }
118
119private:
120 void run(std::chrono::steady_clock::duration timeout)

Callers 1

mainFunction · 0.45

Calls 2

async_writeFunction · 0.85
bufferFunction · 0.85

Tested by

no test coverage detected