gpt4 book ai didi

c++ - 为什么 SO_RCVTIMEO 从监听套接字继承到接受套接字?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:56:55 27 4
gpt4 key购买 nike

<分区>

除了一些 Python documentation,我找不到任何关于此的文档

18.1.4.2. Timeouts and the accept method

If getdefaulttimeout() is not None, sockets returned by the accept() method inherit that timeout. Otherwise, the behaviour depends on settings of the listening socket:

if the listening socket is in blocking mode or in timeout mode, the socket returned by accept() is in blocking mode;

if the listening socket is in non-blocking mode, whether the socket returned by accept() is in blocking or non-blocking mode is operating system-dependent. If you want to ensure cross-platform behaviour, it is recommended you manually override this setting.

我读过这个[问题]:Are socket options inherited across accept() from the listening socket? ,我认为最后的判决仍然是实现定义的。我想在平台上测试比从每个内核读取源代码更容易。

这里说的很清楚,超时选项是继承的。但是在 accept(2) 的联机帮助页上,没有提到这一点。当我在我的一台机器(嵌入式 Linux 机器)上调试一些 C++ 代码时,我发现这非常令人震惊。我希望接受的套接字不会继承此选项。

我在哪里可以找到这个问题的明确答案?

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