For the More Curious: TXTRecords
While Bonjour does not allow a client and server to exchange information, a service published via Bonjour can include additional information that can be read by clients. For example, a printer could tell clients that it is in the third-floor library, or a workstation could display the rules for using it. Every NSNetService has a TXT Record for this purpose.
You can create a TXT Record with an NSDictionary. This dictionary has some restrictions – its keys can only be NSStrings, and its values must be NSData objects that encapsulate an NSString or binary data. Once you have a valid dictionary, you pass it to the class method dataFromTXTRecordDictionary: of NSNetService and set it as an NSNetService’s TXTXRecordData ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access