Re: Directly creating NSNetService
Re: Directly creating NSNetService
- Subject: Re: Directly creating NSNetService
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Mon, 10 Sep 2012 13:05:03 +0100
On 10 Sep 2012, at 07:06, Rick Mann <email@hidden> wrote:
> Awesome, thanks for the explanation. I'm still puzzled by the docs, though. They clearly say I can use it directly.
You can and should construct an NSNetService directly when you're reconnecting to a service that your previously connected to. The classic example of this is a printer. Initially the user chooses a printer by browsing. At this point the printing system remembers the name, type and domain of the chosen NSNetService. Later on, when the user goes to print again, the printing system reconstructs the NSNetService from the name, type and domain and then connects to that. This is the recommended way to remember and then reconnect to a service.
OTOH, if you know the DNS name and port, you should connect via CFStreamCreatePairWithSocketToHost, just like Jens suggested. You can find the code for this in QA1652 "Using NSStreams For A TCP Connection Without NSHost".
<https://developer.apple.com/library/ios/#qa/qa1652/_index.html>
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
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