gpt4 book ai didi

cocoa - 为什么苹果说 NSFileHandle 不应该用于网络?

转载 作者:可可西里 更新时间:2023-11-01 02:52:10 24 4
gpt4 key购买 nike

Apple 说 here “不要将 NSSocketPort (OS X) 或 NSFileHandle 用于一般套接字通信”。

现在我正在努力调试套接字断开连接问题。

如果我们使用 NSFileHandle 会有性能问题吗?

他们不鼓励使用 NSFileHandle 只是因为 NSStream 有助于轻松调试吗?提前致谢。

最佳答案

继续阅读。您链接到的文档解释了为什么您不应该使用 NSFileHandle 进行网络连接:

The NSFileHandle class circumvents the standard networking stack, which carries the following drawbacks:

  • Network connections made with NSFileHandle can be significantly less efficient than those made with the standard networking APIs.
  • Historically, using NSFileHandle for networking has resulted in either extremely poor performance or strange, hard-to-debug failures.
  • There is no straightforward way to use TLS authentication and encryption on connections made with NSFileHandle.
  • In iOS, NSFileHandle does not automatically activate the device’s cellular modem or on-demand VPN.

Instead, use NSStream for remote connections and CFSocket for listening.

关于cocoa - 为什么苹果说 NSFileHandle 不应该用于网络?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20519603/

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