知识卡片
连接过程中的阻塞边界
建立 HTTPS 连接前要完成地址解析、TCP 连接和 TLS 握手。可以把阻塞解析放进受控线程池,同时用 Future 等待连接与握手。不同阶段可各自超时和报错,避免统一归为请求超时后无法辨认瓶颈。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 4. Integrating Networking into Our Own Async Runtime 协议分层与异步连接 · 查看原书依据
The port is 443 because this is the standard port for HTTPS. We then pass a closure into the unblock function. The closure returns the socket address. The unblock function runs blocking code on a thread pool so we can have the async interface on blocking code. While we are resolving the socket address, we can free up the thread to do something else. We
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第04章《Chapter 4. Integrating Networking into Our Own Async Runtime》,协议分层与异步连接(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch04.html#id25)
- 结论依据:原书把 DNS 放入 smol::unblock,建立 TCP 后再做 TLS 握手。
- 原始内容:The port is 443 because this is the standard port for HTTPS. We then pass a closure into the unblock function. The closure returns the socket address. The unblock function runs blocking code on a thread pool so we can have the async interface on blocking code. While we are resolving the socket address, we can free up the thread to do something else. We