Re: NSURLSessionStreamTask
Re: NSURLSessionStreamTask
- Subject: Re: NSURLSessionStreamTask
- From: Jens Alfke <email@hidden>
- Date: Sat, 16 Apr 2016 18:25:01 -0700
On Apr 16, 2016, at 3:29 PM, Daryle Walker < email@hidden> wrote:
The theoretical Gopher-aligned NSURLProtocol class should be able to allocate a NSURLSession object and make a NSURLSessionStreamTask from there.
Oh! I finally looked at the API more closely and saw that the factory method only takes a hostname and a port, not a URL as with the other task types. So this makes a lot more sense to me now. Sorry for being confused.
In that light, NSURLSessionStreamTask seems to be an equivalent of the existing +[NSStream getStreamsToHostWithName:…] API, that fits into the NSURLSession way of doing things. Two specific advantages over NSStream that I see at first glance are: * It has async read and write methods that call completion blocks, which is a lot easier to use than the NSStream delegate API; * It can be scheduled on an NSOperationQueue (NSStream only works with runloops.) * Looks like enabling TLS is a lot simpler than with NSStream.
Plus the fact that you can easily choose to make a direct connection, or ‘tunnel’ the connection through HTTP as WebSockets does.
—Jens |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden