gpt4 book ai didi

c - 当使用 `send` 调用 `send` 有未决数据时,调用 `MSG_MORE` 失败时会发生什么情况?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:07:18 33 4
gpt4 key购买 nike

来自 man 2 send:

MSG_MORE (since Linux 2.4.4)

(…)

Since Linux 2.6, this flag is also supported for UDP sockets, and informs the kernel to package all of the data sent in calls with this flag set into a single datagram which is transmitted only when a call is performed that does not specify this flag.

很好。因此,当我: 1) 调用 send() 并指定标志 MSG_MORE 时; 2) 在没有指定此标志的情况下发出对 send() 的调用并且 send() 失败; 3) 再调用一次 send()

来自调用 (1) 和 (3) 的数据会合并到一个数据报中吗?

换句话说:send() 调用失败算作将此部分附加到整个数据报失败,还是算作发送包含以下内容的整个数据报失败这次对 send() 的调用以及之前使用 MSG_MOREsend() 的任何调用?

我希望是后者,因为我担心在某些情况下错误恢复可能会很困难。

最佳答案

联机帮助页遗漏了一条关键信息:在步骤 (2) 中“发送”的数据将进入在步骤 (1) 中积累的同一数据报。只有这样,整个数据报才真正发送出去。不管这个实际的 send 成功还是失败,数据报都消失了,并且 (3) 不可能与之连接。

关于c - 当使用 `send` 调用 `send` 有未决数据时,调用 `MSG_MORE` 失败时会发生什么情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44120916/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com