Updating the TXT record of a Bonjour service

Q: My application uses CFNetServiceSetProtocolSpecificInformation or setProtocolSpecificInformation to advertise some meta-data corresponding to my Bonjour service, but sometimes I need to update this meta-data after the service is registered. Is that possible?

A: No. The only workaround is to completely unregister the service and then immediately re-register it with the new data. Unfortunately, this causes additional network traffic, so if you need to update this data often, then you should move completely to the low-level DNSServiceDiscovery API.

In Mac OS X 10.2.x, the function DNSServiceRegistrationUpdateRecord from the Mach-based DNSServiceDiscovery API will allow you to update the default TXT record for a service registration. If your application only requires Mac OS X 10.3 and later, you should use the socket-based DNSServiceDiscovery API instead of the Mach-based API. The function DNSServiceUpdateRecord will allow you to update the default TXT record for a service registration.

Both of these functions require that you specify the TTL (Time-to-Live) of the TXT record. The default TTL for TXT records in Mac OS X 10.2.x is 60 seconds, but the default TTL in Mac OS X 10.3.x is 240 seconds. It's recommended that you specify a value of 0 for the TTL, which will allow mDNSResponder to automatically choose the default value.

Document Revision History

2004-07-14Simplified description of work around.
2003-10-23New Document.

Posted: 2004-07-14

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.