gpt4 book ai didi

ios - AFNetworking/NSURLConnection 接收 NSPOSIXErrorDomain Code=9 "The operation couldn’ t 完成。错误的文件描述符”

转载 作者:技术小花猫 更新时间:2023-10-29 10:52:54 25 4
gpt4 key购买 nike

在我使用 AFNetworking/NSURLConnection 向服务器发送请求的应用程序中,我有时(很少)在操作失败 block 中看到此错误:

Error Domain=NSPOSIXErrorDomain Code=9 "The operation couldn’t be completed. Bad file descriptor"

https://devforums.apple.com/message/278770#278770有一个类似问题的答案:

It means that someone has been deallocating file descriptors out from underneath NSURLConnection.

但在我自己的代码中,我不以任何方式触及任何文件描述符流。这只是简单的 GET/POST 请求。

这个问题的原因可能是什么?

有人在他们的 AFNetworking 操作中遇到过这个错误吗?

还有,如果我真的想关闭这个文件描述符,我怎么能故意关闭它呢?这个问题的答案将帮助我更好地理解这个问题。

最佳答案

根据 this Apple TechNote在多任务处理和网络上,如果应用程序被挂起并且套接字被回收,您可以获得 EBADF(POSIX 错误 9)。

Note: When your app resumes execution the actual error returned by a socket's whose resources have been reclaimed is purposely not specified here to allow for future refinements. However, in many cases the error will be EBADF, which is probably not what you were expecting! Under normal circumstances EBADF means that the app has passed an invalid file descriptor to a system call. However, in the case of a socket whose resources have been reclaimed, it does not mean that the file descriptor was invalid, just that the socket is no longer usable.

关于ios - AFNetworking/NSURLConnection 接收 NSPOSIXErrorDomain Code=9 "The operation couldn’ t 完成。错误的文件描述符”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22060991/

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