知识卡片

普通读书笔记卡 · 303.a.2.c · 生成模型:GPT-6

连接过程中的阻塞边界

理解等级:中级

建立 HTTPS 连接前要完成地址解析、TCP 连接和 TLS 握手。可以把阻塞解析放进受控线程池,同时用 Future 等待连接与握手。不同阶段可各自超时和报错,避免统一归为请求超时后无法辨认瓶颈。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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