| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

Mac和iOS的异步 Socket 网络通讯包:GCDAsyncSocket

CocoaAsyncSocket为Mac和iOS提供易于使用和功能强大的异步套接字库。这些类描述如下:

TCP

GCDAsyncSocket and AsyncSocket are TCP/IP socket networking libraries. Here are the key features available in both:

  • Native objective-c, fully self-contained in one class.
    No need to muck around with sockets or streams. This class handles everything for you.

  • Full delegate support
    Errors, connections, read completions, write completions, progress, and disconnections all result in a call to your delegate method.

  • Queued non-blocking reads and writes, with optional timeouts.
    You tell it what to read or write, and it handles everything for you. Queueing, buffering, and searching for termination sequences within the stream - all handled for you automatically.

  • Automatic socket acceptance.
    Spin up a server socket, tell it to accept connections, and it will call you with new instances of itself for each connection.

  • Support for TCP streams over IPv4 and IPv6.
    Automatically connect to IPv4 or IPv6 hosts. Automatically accept incoming connections over both IPv4 and IPv6 with a single instance of this class. No more worrying about multiple sockets.

  • Support for TLS / SSL
    Secure your socket with ease using just a single method call. Available for both client and server sockets.

GCDAsyncSocket is built atop Grand Central Dispatch:

  • Fully GCD based and Thread-Safe
    It runs entirely within its own GCD dispatch_queue, and is completely thread-safe. Further, the delegate methods are all invoked asynchronously onto a dispatch_queue of your choosing. This means parallel operation of your socket code, and your delegate/processing code.

  • The Latest Technology & Performance Optimizations
    Internally the library takes advantage of technologies such as kqueue's to limit system calls and optimize buffer allocations. In other words, peak performance.

AsyncSocket wraps CFSocket and CFStream:

  • Fully Run-loop based
    Use it on the main thread or a worker thread. It plugs into the NSRunLoop with configurable modes.

UDP

GCDAsyncUdpSocket and AsyncUdpSocket are UDP/IP socket networking libraries. Here are the key features available in both:

  • Native objective-c, fully self-contained in one class.
    No need to muck around with low-level sockets. This class handles everything for you.

  • Full delegate support.
    Errors, send completions, receive completions, and disconnections all result in a call to your delegate method.

  • Queued non-blocking send and receive operations, with optional timeouts.
    You tell it what to send or receive, and it handles everything for you. Queueing, buffering, waiting and checking errno - all handled for you automatically.

  • Support for IPv4 and IPv6.
    Automatically send/recv using IPv4 and/or IPv6. No more worrying about multiple sockets.

GCDAsyncUdpSocket is built atop Grand Central Dispatch:

  • Fully GCD based and Thread-Safe
    It runs entirely within its own GCD dispatch_queue, and is completely thread-safe. Further, the delegate methods are all invoked asynchronously onto a dispatch_queue of your choosing. This means parallel operation of your socket code, and your delegate/processing code.

AsyncUdpSocket wraps CFSocket:

  • Fully Run-loop based
    Use it on the main thread or a worker thread. It plugs into the NSRunLoop with configurable modes.

项目主页:http://www.open-open.com/lib/view/home/1409123322135

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1409123322135.html
Objective-C开发 GCDAsyncSocket