[boost-doc-zh] r299 committed - [No log message]

  • From: codesite-noreply@xxxxxxxxxx
  • To: boost-doc-zh-notify@xxxxxxxxxxxxx
  • Date: Tue, 25 Aug 2009 05:54:33 +0000

Revision: 299
Author: totti19851101
Date: Mon Aug 24 22:53:23 2009
Log: [No log message]
http://code.google.com/p/boost-doc-zh/source/detail?r=299

Modified:
 /trunk/doc/html/boost_asio/tutorial/tutdaytime6.html

=======================================
--- /trunk/doc/html/boost_asio/tutorial/tutdaytime6.html Wed May 27 03:09:50 2009 +++ /trunk/doc/html/boost_asio/tutorial/tutdaytime6.html Mon Aug 24 22:53:23 2009
@@ -1,6 +1,6 @@
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>Daytime.6 - An asynchronous UDP daytime server</title>
 <link rel="stylesheet" href="../../boostbook.css" type="text/css">
 <meta name="generator" content="DocBook XSL Stylesheets V1.74.3">
@@ -29,8 +29,7 @@
 </h3></div></div></div>
 <a name="boost_asio.tutorial.tutdaytime6.the_main___function"></a><h5>
 <a name="id1147169"></a>
- <a class="link" href="tutdaytime6.html#boost_asio.tutorial.tutdaytime6.the_main___function">The main()
-        function</a>
+ <a class="link" href="tutdaytime6.html#boost_asio.tutorial.tutdaytime6.the_main___function">主 函数</a>
       </h5>
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
 <span class="special">{</span>
@@ -38,7 +37,7 @@
   <span class="special">{</span>
 </pre>
 <p>
- Create a server object to accept incoming client requests, and run the <a class="link" href="../reference/io_service.html" title="io_service">io_service</a> object. + 创建一个服务器对象去接收来自客户端的请求,然后运行<a class="link" href="../reference/io_service.html" title="io_service">io_service</a>对象。
       </p>
<pre class="programlisting"> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">io_service</span> <span class="identifier">io_service</span><span class="special">;</span> <span class="identifier">udp_server</span> <span class="identifier">server</span><span class="special">(</span><span class="identifier">io_service</span><span class="special">);</span>
@@ -54,15 +53,14 @@
 </pre>
 <a name="boost_asio.tutorial.tutdaytime6.the_udp_server_class"></a><h5>
 <a name="id1147459"></a>
- <a class="link" href="tutdaytime6.html#boost_asio.tutorial.tutdaytime6.the_udp_server_class">The
-        udp_server class</a>
+ <a class="link" href="tutdaytime6.html#boost_asio.tutorial.tutdaytime6.the_udp_server_class">UDP服 务器类</a>
       </h5>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">udp_server</span>
 <span class="special">{</span>
 <span class="keyword">public</span><span class="special">:</span>
 </pre>
 <p>
-        The constructor initialises a socket to listen on UDP port 13.
+        构造函数初始化一个用于监听UDP端口13的socket。
       </p>
<pre class="programlisting"> <span class="identifier">udp_server</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">io_service</span><span class="special">&amp;</span> <span class="identifier">io_service</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">socket_</span><span class="special">(</span><span class="identifier">io_service</span><span class="special">,</span> <span class="identifier">udp</span><span class="special">::</span><span class="identifier">endpoint</span><span class="special">(</span><span class="identifier">udp</span><span class="special">::</span><span class="identifier">v4</span><span class="special">(),</span> <span class="number">13</span><span class="special">))</span>
@@ -75,14 +73,11 @@
   <span class="special">{</span>
 </pre>
 <p>
- The function <a class="link" href="../reference/basic_datagram_socket/async_receive_from.html" title="basic_datagram_socket::async_receive_from">ip::udp::socket::async_receive_from()</a> - will cause the application to listen in the background for a new request. - When such a request is received, the <a class="link" href="../reference/io_service.html" title="io_service">io_service</a> - object will invoke the <code class="computeroutput"><span class="identifier">handle_receive</span><span class="special">()</span></code> function with two arguments: a value of - type boost::system::error_code indicating whether the operation succeeded - or failed, and a <code class="computeroutput"><span class="identifier">size_t</span></code> value - <code class="computeroutput"><span class="identifier">bytes_transferred</span></code> specifying
-        the number of bytes received.
+ 函数<a class="link" href="../reference/basic_datagram_socket/async_receive_from.html" title="basic_datagram_socket::async_receive_from">ip::udp::socket::async_receive_from()</a>将 引发应用程序在后台监听一个新的请求。 + 当这个请求被接收到, <a class="link" href="../reference/io_service.html" title="io_service">io_service</a>对象将 调用函数 + <code class="computeroutput"><span class="identifier">handle_receive</span><span class="special">()</span></code>,这个函数带有两个参数: + 一个用来标识操作是成功还是失败的boost::system::error_code 类型的 值,一个用来指定接收到的字节数的类型为<code class="computeroutput"><span class="identifier">size_t</span></code> + 的<code class="computeroutput"><span class="identifier">bytes_transferred</span></code>变量。
       </p>
<pre class="programlisting"> <span class="identifier">socket_</span><span class="special">.</span><span class="identifier">async_receive_from</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">recv_buffer_</span><span class="special">),</span> <span class="identifier">remote_endpoint_</span><span class="special">,</span>
@@ -92,32 +87,28 @@
   <span class="special">}</span>
 </pre>
 <p>
- The function <code class="computeroutput"><span class="identifier">handle_receive</span><span class="special">()</span></code> will service the client request. + 函数<code class="computeroutput"><span class="identifier">handle_receive</span><span class="special">()</span></code>用于响应客户端的请求。
       </p>
<pre class="programlisting"> <span class="keyword">void</span> <span class="identifier">handle_receive</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span><span class="special">&amp;</span> <span class="identifier">error</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="comment">/*bytes_transferred*/</span><span class="special">)</span>
   <span class="special">{</span>
 </pre>
 <p>
- The <code class="computeroutput"><span class="identifier">error</span></code> parameter contains - the result of the asynchronous operation. Since we only provide the 1-byte - <code class="computeroutput"><span class="identifier">recv_buffer_</span></code> to contain the - client's request, the <a class="link" href="../reference/io_service.html" title="io_service">io_service</a> - object would return an error if the client sent anything larger. We can ignore
-        such an error if it comes up.
+ 异步操作的结果被包含在参数<code class="computeroutput"><span class="identifier">error</span></code>中。 + 如果我们仅仅提供1比特的<code class="computeroutput"><span class="identifier">recv_buffer_</span></code>去响应客户端的请求, + 当客户端发送一个大一点的数据时,<a class="link" href="../reference/io_service.html" title="io_service">io_service</a>对象将 返回一个错误。当这个错误发生时我们可以忽略它。
       </p>
<pre class="programlisting"> <span class="keyword">if</span> <span class="special">(!</span><span class="identifier">error</span> <span class="special">||</span> <span class="identifier">error</span> <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">error</span><span class="special">::</span><span class="identifier">message_size</span><span class="special">)</span>
     <span class="special">{</span>
 </pre>
 <p>
-        Determine what we are going to send.
+        确定需要发送的信息。
       </p>
<pre class="programlisting"> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="identifier">message</span><span class="special">(</span> <span class="keyword">new</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="identifier">make_daytime_string</span><span class="special">()));</span>
 </pre>
 <p>
- We now call <a class="link" href="../reference/basic_datagram_socket/async_send_to.html" title="basic_datagram_socket::async_send_to">ip::udp::socket::async_send_to()</a>
-        to serve the data to the client.
+ 我们现在调用<a class="link" href="../reference/basic_datagram_socket/async_send_to.html" title="basic_datagram_socket::async_send_to">ip::udp::socket::async_send_to()</a>把 数据传送给客户端。
       </p>
<pre class="programlisting"> <span class="identifier">socket_</span><span class="special">.</span><span class="identifier">async_send_to</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(*</span><span class="identifier">message</span><span class="special">),</span> <span class="identifier">remote_endpoint_</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">udp_server</span><span class="special">::</span><span class="identifier">handle_send</span><span class="special">,</span> <span class="keyword">this</span><span class="special">,</span> <span class="identifier">message</span><span class="special">,</span>
@@ -125,27 +116,21 @@
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">placeholders</span><span class="special">::</span><span class="identifier">bytes_transferred</span><span class="special">));</span>
 </pre>
 <p>
- When initiating the asynchronous operation, and if using boost::bind(), you - must specify only the arguments that match the handler's parameter list. - In this program, both of the argument placeholders (boost::asio::placeholders::error - and boost::asio::placeholders::bytes_transferred) could potentially have
-        been removed.
+ 当启动一个异步操作时,如果使用boost::bind(),你必须指定符合句柄参数 列表的参数。在本例中,任何一个参数占位符(boost::asio::placeholders::error 和boost::asio::placeholders::bytes_transferred)皆可被隐式地移除。
       </p>
 <p>
-        Start listening for the next client request.
+        为客户端的下一次请求启动监听。
       </p>
<pre class="programlisting"> <span class="identifier">start_receive</span><span class="special">();</span>
 </pre>
 <p>
- Any further actions for this client request are now the responsibility of - <code class="computeroutput"><span class="identifier">handle_send</span><span class="special">()</span></code>. + 任何对客户端请求下一步操作现在都由<code class="computeroutput"><span class="identifier">handle_send</span><span class="special">()</span></code>责任。
       </p>
 <pre class="programlisting">    <span class="special">}</span>
   <span class="special">}</span>
 </pre>
 <p>
- The function <code class="computeroutput"><span class="identifier">handle_send</span><span class="special">()</span></code> is invoked after the service request has
-        been completed.
+ 当服务请求处理完成后,函数<code class="computeroutput"><span class="identifier">handle_send</span><span class="special">()</span></code>将被调用。
       </p>
<pre class="programlisting"> <span class="keyword">void</span> <span class="identifier">handle_send</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="comment">/*message*/</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span><span class="special">&amp;</span> <span class="comment">/*error*/</span><span class="special">,</span>
@@ -159,18 +144,16 @@
 <span class="special">};</span>
 </pre>
 <p>
- See the <a class="link" href="tutdaytime6/src.html" title="Source listing for Daytime.6">full source listing</a> + 查看<a class="link" href="tutdaytime6/src.html" title="Source listing for Daytime.6">本例全部源代码</a>
       </p>
 <p>
- Return to the <a class="link" href="../tutorial.html" title="Tutorial">tutorial index</a> + 返回<a class="link" href="../tutorial.html" title="Tutorial">指南 </a>
       </p>
 <p>
- Previous: <a class="link" href="tutdaytime5.html" title="Daytime.5 - A synchronous UDP daytime server">Daytime.5 - A synchronous
-        UDP daytime server</a>
+ 前一例: <a class="link" href="tutdaytime5.html" title="Daytime.5 - A synchronous UDP daytime server">Daytime.5 - 同步UDP daytime服务器</a>
       </p>
 <p>
- Next: <a class="link" href="tutdaytime7.html" title="Daytime.7 - A combined TCP/UDP asynchronous server">Daytime.7 - A combined
-        TCP/UDP asynchronous server</a>
+ 后一例: <a class="link" href="tutdaytime7.html" title="Daytime.7 - A combined TCP/UDP asynchronous server">Daytime.7 - 整合了TCP/UDP的同步服务 器</a>
       </p>
 </div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>

Other related posts:

  • » [boost-doc-zh] r299 committed - [No log message] - codesite-noreply