AsyncSocket is a class that wraps CFSocket and CFStream. I've compared it against DizSocket, NetSocket, and SmallSockets, and I dare say that AsyncSocket is the best socket class out there short of OmniNetworking.
Here are some key features of "AsyncSocket":
· Queued non-blocking reads and writes, with timeouts. You tell it what to read or write and get out of the way. It'll call you when it is 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, 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.
What's New in This Release:
· Eliminated empty data returns from -readDataWithTag:.
· Added per-socket user data.
· More complete NSError messages.
· Fixed null-padding at end of recovered data.
· Mac OS X 10.4 or higher and Apple Developer Tools.