CocoaAsyncSocket supports TCP and UDP. The AsyncSocket class is for TCP, and the AsyncUdpSocket class is for UDP. Each class is described below.
AsyncSocket is a TCP/IP socket networking library that wraps CFSocket and CFStream. It offers asynchronous operation, and a native cocoa class complete with delegate support. Here are the key features:
Queued non-blocking reads and writes, with optional timeouts. You tell it what to read or write, and it will call you when it's done.
Automatic socket acceptance. If you tell it to accept connections, it will call you with new instances of itself for each connection. You can, of course, disconnect them immediately.
Delegate support. Errors, connections, accepts, read completions, write completions, progress, and disconnections all result in a call to your delegate method.
Run-loop based, not thread based. Although you can use it on main or worker threads, you don't have to. It calls the delegate methods asynchronously using NSRunLoop. The delegate methods include a socket parameter, allowing you to distinguish between many instances.
Self-contained in one class. You don't need to muck around with streams or sockets. The class handles all of that.
Support for TCP streams over IPv4 and IPv6.
The library is public domain, originally written by Dustin Voss. Now available in a public setting to allow and encourage its continued support.
AsyncUdpSocket is a UDP/IP socket networking library that wraps CFSocket. It works almost exactly like the TCP version, but is designed specifically for UDP. This includes queued non-blocking send/receive operations, full delegate support, run-loop based, self-contained class, and support for IPv4 and IPv6.
发布评论
评论(4)
编辑于 2015/03/19: Socket.IO 人员创建了他们自己的支持 Socket.IO v1.0+ 的 iOS 库。在这里获取它: https://github.com/socketio/socket.io-client- swift
旧答案
我更新了fpotter的socket.io库以使用版本0.7.2 - 0.9.x。
它支持套接字和 XHRpolling。
https://github.com/pkyeck/socket.IO-objc
也许你想要检查一下。
edited 2015/03/19: The Socket.IO guys created their own iOS library that supports Socket.IO v1.0+. Get it here: https://github.com/socketio/socket.io-client-swift
old answer
I updated fpotter's socket.io library to work with version 0.7.2 - 0.9.x.
It supports sockets and XHRpolling.
https://github.com/pkyeck/socket.IO-objc
Maybe you want to check it out.
或者看看 cocoaasyncsocket:
Or have a look at cocoaasyncsocket:
如果您打算制作本机应用程序,我建议您查看有关流式传输和套接字的 Apple 文档。 http://developer.apple.com/library/ ios/#documentation/cocoa/Conceptual/Streams/Streams.html
I'd suggest checking out the Apple documentation for streaming and sockets if you are planning on doing an native app. http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Streams/Streams.html
看看这个:https://github.com/fpotter/socketio-cocoa
Check this out: https://github.com/fpotter/socketio-cocoa