     <span class="phrase"><a name="boost_asio.reference.basic_streambuf.examples"></a></span><a class="link" href="basic_streambuf.html#boost_asio.reference.basic_streambuf.examples">Examples</a>
      </h5>
<p>
        Writing directly from an streambuf to a socket:
      </p>
<pre class="programlisting">boost::asio::streambuf b;
std::ostream os(&amp;b);
os &lt;&lt; "Hello, World!\n";

// try sending some data in input sequence
size_t n = sock.send(b.data());

b.consume(n); // sent data is removed from inp