For the More Curious: TXT Records

Besides the standard information for a service (host, port, name), the DNS record used to publish the services has a TXT record. This is a place where you can put any sort of data that clients might want to know about. For example, your chatter server might want to advertise the number of users already connected. It could use the TXT record to do this. NSNetService has a method that would be used on the server side:

- (BOOL) setTXTRecordData: (NSData *) data;

On the client side, you would ask the NSNetService for the data using:

- (NSData *)TXTRecordData;

Of course, the server might change the TXT record. (For example, if more people subscribe, your chatterd server would want to change the advertised number of ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.