Are there any frameworks or sample code that illustrate best practices for doing TCP socket I/O using GCD (dispatch queues and/or NSOperationQueues?)
The conundrum seems to be that: * dispatch_io looks like a great lightweight mechanism for doing I/O on dispatch queues. But since it operates on raw file descriptors it doesn’t support SSL. And implementing SSL support using SecureTransport is messy. * CFStream on the other hand has transparent support for SSL. But it’s an old API that uses runloops to schedule callbacks. So you have to use a workaround like creating a background thread with a runloop, and making the callbacks trampoline to your dispatch queue.*
Thus far I’ve been using GCDAsyncSocket, but it’s a huge and impenetrable piece of code and I’d like to ditch it for something smaller and more manageable. I’d love to use dispatch_io, but SSL is an absolute necessity for me, and remembering my last experience working with SecureTransport, I’m not eager to do it again.
—Jens
|