msgid ""
msgstr ""
"Project-Id-Version: Chinese (Simplified Han script) (Boost Beast Translation "
"(zh_Hans))\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-07 11:02+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Chinese (Simplified Han script) <https://"
"insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/"
"doc-qbk-03-core-3-timeouts-qbk/zh_Hans/>\n"
"Language: zh_Hans\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 2026.5\n"

#. type: section title
#: 10
#, fuzzy
msgid "Timeouts __example__"
msgstr "Timeouts __example__"

#. type: paragraph
#: 12
#, fuzzy
msgid ""
"Network programs must handle adverse connection conditions; the most common "
"is that a connected peer goes offline unexpectedly. Protocols have no way of "
"identifying this reliably: the peer is offline after all, and unable to send "
"a message announcing the absence. A peer can go offline for various reasons:"
msgstr ""
"Network programs must handle adverse connection conditions; the most common "
"is that a connected peer goes offline unexpectedly. Protocols have no way of "
"identifying this reliably: the peer is offline after all, and unable to send "
"a message announcing the absence. A peer can go offline for various reasons:"

#. type: paragraph
#: 24
#, fuzzy
msgid ""
"To determine when a peer is offline or idle, a program will implement a "
"[@https://en.wikipedia.org/wiki/Timeout_(computing) timeout] algorithm, "
"which closes the connection after a specified amount of time if some "
"condition is met. For example, if no data is received for the duration. A "
"timeout may be used to:"
msgstr ""
"To determine when a peer is offline or idle, a program will implement a "
"[@https://en.wikipedia.org/wiki/Timeout_(computing) timeout] algorithm, "
"which closes the connection after a specified amount of time if some "
"condition is met. For example, if no data is received for the duration. A "
"timeout may be used to:"

#. type: paragraph
#: 36
#, fuzzy
msgid ""
"Traditionally, programs use a [@boost:/doc/html/boost_asio/reference/"
"steady_timer.html `net::steady_timer`] to determine when a timeout occurs, "
"and then call [@boost:/doc/html/boost_asio/reference/basic_socket/close/"
"overload2.html `close`] on the socket to release the resources. The "
"complexity of managing a separate timer is often a source of [@http://"
"www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1269r0.html#timers "
"frustration] for non-experts."
msgstr ""
"Traditionally, programs use a [@boost:/doc/html/boost_asio/reference/"
"steady_timer.html `net::steady_timer`] to determine when a timeout occurs, "
"and then call [@boost:/doc/html/boost_asio/reference/basic_socket/close/"
"overload2.html `close`] on the socket to release the resources. The "
"complexity of managing a separate timer is often a source of [@http://"
"www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1269r0.html#timers "
"frustration] for non-experts."

#. type: paragraph
#: 46
#, fuzzy
msgid "For portability reasons, networking does not provide timeouts"
msgstr "For portability reasons, networking does not provide timeouts"

#. type: paragraph
#: 50
#, fuzzy
msgid ""
"To simplify the handling of timeouts, these provided types wrap a [@boost:/"
"doc/html/boost_asio/reference/basic_stream_socket.html "
"`net::basic_stream_socket`] to provide additional features:"
msgstr ""
"To simplify the handling of timeouts, these provided types wrap a [@boost:/"
"doc/html/boost_asio/reference/basic_stream_socket.html "
"`net::basic_stream_socket`] to provide additional features:"

#. type: table cell
#: 54
#, fuzzy
msgid "[link beast.ref.boost__beast__tcp_stream `tcp_stream`]"
msgstr "[link beast.ref.boost__beast__tcp_stream `tcp_stream`]"

#. type: table cell
#: 54
#, fuzzy
msgid ""
"[itemized_list [Timeouts for logical operations] [[@boost:/doc/html/"
"boost_asio/reference/ip__tcp.html `net::ip::tcp`] protocol] [[@boost:/doc/"
"html/boost_asio/reference/executor.html `net::executor`] executor] [[link "
"beast.ref.boost__beast__unlimited_rate_policy `unlimited_rate_policy`] rate "
"limits] ]"
msgstr ""
"[itemized_list [Timeouts for logical operations] [[@boost:/doc/html/"
"boost_asio/reference/ip__tcp.html `net::ip::tcp`] protocol] [[@boost:/doc/"
"html/boost_asio/reference/executor.html `net::executor`] executor] [[link "
"beast.ref.boost__beast__unlimited_rate_policy `unlimited_rate_policy`] rate "
"limits] ]"

#. type: table cell
#: 54
#, fuzzy
msgid "[link beast.ref.boost__beast__basic_stream `basic_stream`]"
msgstr "[link beast.ref.boost__beast__basic_stream `basic_stream`]"

#. type: table cell
#: 54
#, fuzzy
msgid ""
"[itemized_list [Timeouts for logical operations] [Configurable __Protocol__ "
"type] [Configurable __Executor__ type] [Configurable __RatePolicy__ type] ]"
msgstr ""
"[itemized_list [Timeouts for logical operations] [Configurable __Protocol__ "
"type] [Configurable __Executor__ type] [Configurable __RatePolicy__ type] ]"

#. type: heading
#: 76
#, fuzzy
msgid "Construction"
msgstr "Construction"

#. type: paragraph
#: 78
#, fuzzy
msgid ""
"The `tcp_stream` is designed as a replacement for [@boost:/doc/html/"
"boost_asio/reference/ip__tcp/socket.html `net::ip::tcp::socket`]. Any "
"program which currently uses a socket, can switch to a `tcp_stream` and "
"achieve the features above (although some interfaces are different, see "
"below). Networking now allows I/O objects to construct with any instance of "
"__ExecutionContext__ or __Executor__ objects. Here we construct a stream "
"which uses a particular I/O context to dispatch completion handlers:"
msgstr ""
"The `tcp_stream` is designed as a replacement for [@boost:/doc/html/"
"boost_asio/reference/ip__tcp/socket.html `net::ip::tcp::socket`]. Any "
"program which currently uses a socket, can switch to a `tcp_stream` and "
"achieve the features above (although some interfaces are different, see "
"below). Networking now allows I/O objects to construct with any instance of "
"__ExecutionContext__ or __Executor__ objects. Here we construct a stream "
"which uses a particular I/O context to dispatch completion handlers:"

#. type: paragraph
#: 88
#, fuzzy
msgid "Alternatively, we can construct the stream from an executor:"
msgstr "Alternatively, we can construct the stream from an executor:"

#. type: paragraph
#: 92
#, fuzzy
msgid ""
"The function [@boost:/doc/html/boost_asio/reference/make_strand.html "
"`make_strand`] returns a strand constructed from an execution context or "
"executor. When a [@boost:/doc/html/boost_asio/reference/strand.html "
"`net::strand`] is chosen for the stream's executor, all completion handlers "
"which do not already have an associated executor will use the strand. This "
"is both a notational convenience (no need for `strand::wrap` or "
"`bind_executor` at call sites) and a measure of safety, as it is no longer "
"possible to forget to use the strand."
msgstr ""
"The function [@boost:/doc/html/boost_asio/reference/make_strand.html "
"`make_strand`] returns a strand constructed from an execution context or "
"executor. When a [@boost:/doc/html/boost_asio/reference/strand.html "
"`net::strand`] is chosen for the stream's executor, all completion handlers "
"which do not already have an associated executor will use the strand. This "
"is both a notational convenience (no need for `strand::wrap` or "
"`bind_executor` at call sites) and a measure of safety, as it is no longer "
"possible to forget to use the strand."

#. type: heading
#: 106
#, fuzzy
msgid "Connecting"
msgstr "Connecting"

#. type: paragraph
#: 108
#, fuzzy
msgid ""
"Before data can be exchanged, the stream needs to be connected to a peer. "
"The following code sets a timeout for an asynchronous connect operation. In "
"Beast, functions to connect to a range of endpoints (such as the range "
"returned by [@boost:/doc/html/boost_asio/reference/ip__basic_resolver/"
"resolve/overload3.html `net::ip::tcp::resolver::resolve`]) are members of "
"the class rather than free functions such as [@boost:/doc/html/boost_asio/"
"reference/async_connect.html `net::async_connect`]."
msgstr ""
"Before data can be exchanged, the stream needs to be connected to a peer. "
"The following code sets a timeout for an asynchronous connect operation. In "
"Beast, functions to connect to a range of endpoints (such as the range "
"returned by [@boost:/doc/html/boost_asio/reference/ip__basic_resolver/"
"resolve/overload3.html `net::ip::tcp::resolver::resolve`]) are members of "
"the class rather than free functions such as [@boost:/doc/html/boost_asio/"
"reference/async_connect.html `net::async_connect`]."

#. type: paragraph
#: 118
#, fuzzy
msgid ""
"A server will use an acceptor bound to a particular IP address and port to "
"listen to and receive incoming connection requests. The acceptor returns an "
"ordinary socket. A `tcp_stream` can be move-constructed from the underlying "
"`basic_stream_socket` thusly:"
msgstr ""
"A server will use an acceptor bound to a particular IP address and port to "
"listen to and receive incoming connection requests. The acceptor returns an "
"ordinary socket. A `tcp_stream` can be move-constructed from the underlying "
"`basic_stream_socket` thusly:"

#. type: heading
#: 127
#, fuzzy
msgid "Reading and Writing"
msgstr "Reading and Writing"

#. type: paragraph
#: 129
#, fuzzy
msgid ""
"Timeouts apply to the logical operation, expressed as a series of "
"asynchronous calls, rather than just the next call. This code reads a line "
"from the stream and writes it back. Both the read and the write must "
"complete within 30 seconds from when the timeout was set; the timer is not "
"reset between operations."
msgstr ""
"Timeouts apply to the logical operation, expressed as a series of "
"asynchronous calls, rather than just the next call. This code reads a line "
"from the stream and writes it back. Both the read and the write must "
"complete within 30 seconds from when the timeout was set; the timer is not "
"reset between operations."

#. type: paragraph
#: 136
#, fuzzy
msgid ""
"Since reads and writes can take place concurrently, it is possible to have "
"two simultaneous logical operations where each operation either only reads, "
"or only writes. The beginning of a new read or write operation will use the "
"most recently set timeout. This will not affect operations that are already "
"outstanding."
msgstr ""
"Since reads and writes can take place concurrently, it is possible to have "
"two simultaneous logical operations where each operation either only reads, "
"or only writes. The beginning of a new read or write operation will use the "
"most recently set timeout. This will not affect operations that are already "
"outstanding."

#. type: paragraph
#: 144
#, fuzzy
msgid ""
"When a timeout is set, it cancels any previous read or write timeout for "
"which no outstanding operation is in progress. Algorithms which loop over "
"logical operations simply need to set the timeout once before the logical "
"operation, it is not necessary to call `expires_never` in this case. Here we "
"implement an algorithm which continuously echoes lines back, with a timeout. "
"This example is implemented as a complete function."
msgstr ""
"When a timeout is set, it cancels any previous read or write timeout for "
"which no outstanding operation is in progress. Algorithms which loop over "
"logical operations simply need to set the timeout once before the logical "
"operation, it is not necessary to call `expires_never` in this case. Here we "
"implement an algorithm which continuously echoes lines back, with a timeout. "
"This example is implemented as a complete function."

#. type: heading
#: 155
#, fuzzy
msgid "https_get"
msgstr "https_get"

#. type: paragraph
#: 157
#, fuzzy
msgid ""
"It is important to note that all of the examples thus far which perform "
"reads and writes with a timeout, make use of the existing networking stream "
"algorithms. As these algorithms are written generically to work with any "
"object meeting the stream requirements, they transparently support timeouts "
"when used with `tcp_stream`. This can be used to enable timeouts for stream "
"wrappers that do not currently support timeouts."
msgstr ""
"It is important to note that all of the examples thus far which perform "
"reads and writes with a timeout, make use of the existing networking stream "
"algorithms. As these algorithms are written generically to work with any "
"object meeting the stream requirements, they transparently support timeouts "
"when used with `tcp_stream`. This can be used to enable timeouts for stream "
"wrappers that do not currently support timeouts."

#. type: paragraph
#: 164
#, fuzzy
msgid ""
"The following code establishes an encrypted connection, writes an HTTP "
"request, reads the HTTP response, and closes the connection gracefully. If "
"these operations take longer than 30 seconds total, a timeout occurs. This "
"code is intended to show how `tcp_stream` can be used to enable timeouts "
"across unmodified stream algorithms which were not originally written to "
"support timing out, and how a blocking algorithm may be written from "
"asynchronous intermediate operations."
msgstr ""
"The following code establishes an encrypted connection, writes an HTTP "
"request, reads the HTTP response, and closes the connection gracefully. If "
"these operations take longer than 30 seconds total, a timeout occurs. This "
"code is intended to show how `tcp_stream` can be used to enable timeouts "
"across unmodified stream algorithms which were not originally written to "
"support timing out, and how a blocking algorithm may be written from "
"asynchronous intermediate operations."

#. type: section title
#: 178
#, fuzzy
msgid "Rate Limiting __example__"
msgstr "Rate Limiting __example__"

#. type: paragraph
#: 180
#, fuzzy
msgid ""
"The [link beast.ref.boost__beast__basic_stream `basic_stream`] class "
"template supports an additional `RatePolicy` template parameter. Objects of "
"this type must meet the requirements of __RatePolicy__. They are used to "
"implement rate limiting or bandwidth management. The default policy for "
"`basic_stream` and `tcp_stream` is [link "
"beast.ref.boost__beast__unlimited_rate_policy `unlimited_rate_policy`], "
"which places no limits on reading and writing. The library comes with the "
"[link beast.ref.boost__beast__simple_rate_policy `simple_rate_policy`], "
"allowing for independent control of read and write limits expressed in terms "
"of bytes per second. The follow code creates an instance of the basic stream "
"with a simple rate policy, and sets the read and write limits:"
msgstr ""
"The [link beast.ref.boost__beast__basic_stream `basic_stream`] class "
"template supports an additional `RatePolicy` template parameter. Objects of "
"this type must meet the requirements of __RatePolicy__. They are used to "
"implement rate limiting or bandwidth management. The default policy for "
"`basic_stream` and `tcp_stream` is [link "
"beast.ref.boost__beast__unlimited_rate_policy `unlimited_rate_policy`], "
"which places no limits on reading and writing. The library comes with the "
"[link beast.ref.boost__beast__simple_rate_policy `simple_rate_policy`], "
"allowing for independent control of read and write limits expressed in terms "
"of bytes per second. The follow code creates an instance of the basic stream "
"with a simple rate policy, and sets the read and write limits:"

#. type: paragraph
#: 195
#, fuzzy
msgid ""
"More sophisticated rate policies can be implemented as user-defined types "
"which meet the requirements of __RatePolicy__. Here, we develop a rate "
"policy that measures the instantaneous throughput of reads and writes. First "
"we write a small utility class that applies an exponential smoothing "
"function to a series of discrete rate samples, to calculate instantaneous "
"throughput."
msgstr ""
"More sophisticated rate policies can be implemented as user-defined types "
"which meet the requirements of __RatePolicy__. Here, we develop a rate "
"policy that measures the instantaneous throughput of reads and writes. First "
"we write a small utility class that applies an exponential smoothing "
"function to a series of discrete rate samples, to calculate instantaneous "
"throughput."

#. type: paragraph
#: 203
#, fuzzy
msgid ""
"Then we define our rate policy object. We friend the type [link "
"beast.ref.boost__beast__rate_policy_access `rate_policy_access`] to allow "
"our implementation to be private, but still allow the `basic_stream` access "
"to call the required functions. This lets us avoid having to write a "
"cumbersome friend declaration for the `basic_stream` class template. Public "
"members of rate policy objects become part of the stream object's interface, "
"through a call to `rate_policy`."
msgstr ""
"Then we define our rate policy object. We friend the type [link "
"beast.ref.boost__beast__rate_policy_access `rate_policy_access`] to allow "
"our implementation to be private, but still allow the `basic_stream` access "
"to call the required functions. This lets us avoid having to write a "
"cumbersome friend declaration for the `basic_stream` class template. Public "
"members of rate policy objects become part of the stream object's interface, "
"through a call to `rate_policy`."

#. type: paragraph
#: 213
#, fuzzy
msgid ""
"To use our new policy we declare an instance of the stream, and then use it "
"with stream algorithms as usual. At any time, we can determine the current "
"read or write rates by calling into the policy."
msgstr ""
"To use our new policy we declare an instance of the stream, and then use it "
"with stream algorithms as usual. At any time, we can determine the current "
"read or write rates by calling into the policy."
