|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
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.以下代码用于建立加密连接、发送 HTTP 请求、接收 HTTP 响应,并正常关闭连接。如果这些操作的总耗时超过 30 秒,就会触发超时。这段代码主要展示两件事:一是如何用 `tcp_stream` 为原本不支持超时的流算法添加上超时功能,二是如何通过异步中间操作来构建一个阻塞算法。