gpt4 book ai didi

c - 什么是 SOCKET accept() 错误 errno 316?

转载 作者:太空宇宙 更新时间:2023-11-04 10:52:26 24 4
gpt4 key购买 nike

在 OSX 上,在绑定(bind)和监听套接字上调用 accept() 后,我不断收到套接字错误 316。我得到一个有效的套接字返回,我相信我可以很好地使用它,(虽然我可能不是,我需要仔细检查这个,因为我随时接受数百个连接)但是错误号已经设置。

我正在努力理解 the documentation on the unix accept(2) man pages哪些注释(顺便说一句,apple's accept() documentation 中缺少)

Linux accept() (and accept4()) passes already-pending network errors on the new socket as an error code from accept(). This behavior differs from other BSD socket implementations. For reliable operation the application should detect the network errors defined for the protocol after accept() and treat them like EAGAIN by retrying.

现在,316 计算为 256 与 ETIMEDOUT(60) 的“或”运算。所以,我很好奇我应该如何处理这个问题;

  1. 如果在 accept() 之后设置了任何错误,我是否应该再次 accept()?
  2. 我应该关闭()接受 DID 返回的 SOCKET 吗?
  3. 是unixerrno代码的8位? (我看到的所有代码都 <128)这是一个内存中设置了错误的位,或者它是一个特殊的标志,比如警告(我找不到关于 errno 格式的任何文档)
  4. 这个错误是否意味着我刚刚从堆栈中弹出的连接超时...本身和操作系统断开了它们,或者我没有足够快地接受()?

最佳答案

除非 accept() 已返回 -1,否则不要检查 errno。如果 accept() 返回有效的文件描述符,则 errno 的值为 undefined

关于c - 什么是 SOCKET accept() 错误 errno 316?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30257722/

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