gpt4 book ai didi

ios - GCDAsyncSocket 和 AsyncSocket 有什么不同?

转载 作者:可可西里 更新时间:2023-11-01 06:24:07 25 4
gpt4 key购买 nike

一个是GCD另一个是Runloop?很抽象,我的TCP连接怎么选择?非常感谢,我只在github上找到了如何使用GCDAsyncSocket,但不知道如何选择。

最佳答案

希望对你有帮助:

Even if you're on iOS only, there will likely be multi-core iOS devices in the near future. And GCD will be an excellent way to take advantage of the additional resources with GCDAsyncSocket

GCDAsyncSocket

  • GCDAsyncSocket 最低要求:Mac OS X 10.6+ 或 iOS 4.0+

  • GCDAsyncSocket 的性能比 AsyncSocket 好得多。

  • 考虑将加密/解密(不是 SSL/TLS)卸载到另一个线程上,在我看来,采用 GCD 的方式是更好的选择。

GCDAsyncSocket 的具体功能包括:

    1. Classic delegate-style support.
2. It allows allows for parallel socket IO and data processing, as well as easy thread-safety.
3. Queued non-blocking reads and writes, with optional timeouts.
4. Automatic support for IPv4 and IPv6.
5. SSL/TLS support.
6. Built upon the latest technologies such as queues and GCD.
7. Self-contained in one class.
You don't need to muck around with streams or sockets. The class handles all of that.

AsyncSocket

AsyncSocket 库由一个类组成,也称为AsyncSocket。 AsyncSocket 的一个实例代表一个套接字,它可以是一个监听套接字或一个连接套接字。

  • 如果您需要支持 Mac OS X 10.6+ 或 iOS 4.0+ 之前的操作系统版本,那么您现在需要坚持使用 AsyncSocket。

    <
  • AsyncSocket 提供易于集成的“即发即弃”网络,使您的应用程序可以轻松支持网络。

功能包括:

•   Queued non-blocking reads and writes, with timeouts.
• Automatic socket acceptance.
• Delegate support.
• Run-loop based, not thread based.
• Self-contained in one class. You do not need to muck around with a collection of stream or socket instances. The class handles all of that.
• Support for TCP streams. AsyncSocket does not support UDP or multicast sockets.
• Based on Apple’s own CFSocket and CFStream Carbon APIs.

引用 Reference_GCDAsyncSocket

引用 About AsyncSocket

关于ios - GCDAsyncSocket 和 AsyncSocket 有什么不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38237286/

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