Ios GCDAsyncSocket和AsyncSocket有什么不同?

Ios GCDAsyncSocket和AsyncSocket有什么不同?,ios,objective-c,gcdasyncsocket,Ios,Objective C,Gcdasyncsocket,一个是GCD,另一个是Runloop?这是抽象的,如何为我的TCP连接选择一个?非常感谢,我只知道如何在github上使用GCDAsyncSocket,但不知道如何选择一个。希望这可以帮助您: 即使您只使用iOS,在不久的将来也可能会出现多核iOS设备。而GCD将是利用GCDAsyncSocket的额外资源的极好方式 GCDAsyncSocket GCDAsyncSocket的最低要求:Mac OS X 10.6+或iOS 4.0+ GCDAsyncSocket的性能比AsyncSocket好

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

希望这可以帮助您:

即使您只使用iOS,在不久的将来也可能会出现多核iOS设备。而GCD将是利用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.
•   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.
异步套接字

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

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

  • AsyncSocket提供了易于集成的“触发并忘记”网络,使您的应用程序易于支持网络

功能包括:

    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.
•   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.
参考文献

参考文献