问题描述
一个是GCD,一个是Runloop?很抽象,我的TCP连接怎么选?非常感谢,我在github上只找到了GCDAsyncSocket的使用方法,不知道怎么选.
One is GCD and other is Runloop?It is abstract,how to choose one for my TCP connect ?Very thankful,i only find how to use GCDAsyncSocket on github,but dont know how to choose one.
推荐答案
希望可以帮到你:
即使您只使用 iOS,在不久的将来也可能会有多核 iOS 设备.GCD 将是利用 GCDAsyncSocket
GCDAsyncSocket
GCDAsyncSocket 的最低要求:Mac OS X 10.6+ 或 iOS 4.0+
The minimum requirements for GCDAsyncSocket:Mac OS X 10.6+ or iOS 4.0+
GCDAsyncSocket 的性能比 AsyncSocket 好得多.
GCDAsyncSocket performs much better than AsyncSocket.
考虑将加密/解密(不是 SSL/TLS)卸载到另一个线程上,在我看来,采用 GCD 的方式将是更好的选择.
Considering off-loading the encryption/descryption (not SSL/TLS) onto another thread and it seems to me that going the way of GCD would be the better alternative.
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 的一个实例代表一个套接字,可以是监听套接字或连接套接字.
The AsyncSocket library is composed of one class, also called AsyncSocket. An instance of AsyncSocket represents one socket, which may be a listen socket or a connect socket.
如果您需要支持Mac OS X 10.6+或iOS 4.0+之前的操作系统版本,那么您现在需要坚持使用AsyncSocket.
If you need to support OS versions prior to Mac OS X 10.6+ or iOS 4.0+, then you'll need to stick with AsyncSocket for now.
AsyncSocket 提供易于集成的即发即弃"网络,使您的应用程序能够轻松支持网络.
AsyncSocket provides easy-to-integrate "fire and forget" networking that makes it easy for your application to support networking.
功能包括:
• 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.
这篇关于GCDAsyncSocket 和 AsyncSocket 有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!