summaryrefslogtreecommitdiff
path: root/doc/html/boost_asio/tutorial/tutdaytime5.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/boost_asio/tutorial/tutdaytime5.html')
-rw-r--r--doc/html/boost_asio/tutorial/tutdaytime5.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/html/boost_asio/tutorial/tutdaytime5.html b/doc/html/boost_asio/tutorial/tutdaytime5.html
index 55162a4698..f0fdada957 100644
--- a/doc/html/boost_asio/tutorial/tutdaytime5.html
+++ b/doc/html/boost_asio/tutorial/tutdaytime5.html
@@ -47,15 +47,38 @@
Wait for a client to initiate contact with us. The remote_endpoint object
will be populated by <a class="link" href="../reference/basic_datagram_socket/receive_from.html" title="basic_datagram_socket::receive_from">ip::udp::socket::receive_from()</a>.
</p>
+<pre class="programlisting"> for (;;)
+ {
+ boost::array&lt;char, 1&gt; recv_buf;
+ udp::endpoint remote_endpoint;
+ boost::system::error_code error;
+ socket.receive_from(boost::asio::buffer(recv_buf), remote_endpoint);
+</pre>
<p>
Determine what we are going to send back to the client.
</p>
+<pre class="programlisting"> std::string message = make_daytime_string();
+</pre>
<p>
Send the response to the remote_endpoint.
</p>
+<pre class="programlisting"> boost::system::error_code ignored_error;
+ socket.send_to(boost::asio::buffer(message),
+ remote_endpoint, 0, ignored_error);
+ }
+ }
+</pre>
<p>
Finally, handle any exceptions.
</p>
+<pre class="programlisting"> catch (std::exception&amp; e)
+ {
+ std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
+ }
+
+ return 0;
+}
+</pre>
<p>
See the <a class="link" href="tutdaytime5/src.html" title="Source listing for Daytime.5">full source listing</a>
</p>