DNS Service Discovery C

Overview

See the Overview section above for header-level documentation.

Overview

Included Headers

Symbols

Version checking

DNSServiceGetProperty

Gets the specified property of a service.

Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions

DNSServiceProcessResult

Reads a reply from the daemon, calling the appropriate application callback.

DNSServiceRefDeallocate

Terminates a connection with the daemon and frees memory associated with the DNSServiceRef.

DNSServiceRefSockFD

Accesses underlying Unix domain socket for an initialized DNSServiceRef.

Unified lookup of both IPv4 and IPv6 addresses for a fully qualified hostname

DNSServiceGetAddrInfo

Queries for the IP address of a hostname by using either Multicast or Unicast DNS.

TXT Record Parsing Functions

A typical calling sequence for TXT record parsing is something like:

Receive TXT record data in DNSServiceResolve callback

 
 if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
 val1ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key1", &len1);
 val2ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key2", &len2);
 ...
 memcpy(myval1, val1ptr, len1);
 memcpy(myval2, val2ptr, len2);
 ...
 return;
 

If you wish to retain the values after return from the DNSServiceResolve callback, then you need to copy the data to your own storage using memcpy() or similar, as shown in the example above.

If for some reason you need to parse a TXT record you built yourself using the TXT record construction functions above, then you can do that using TXTRecordGetLength and TXTRecordGetBytesPtr calls: TXTRecordGetValue(TXTRecordGetLength(x), TXTRecordGetBytesPtr(x), key, &len);

Most applications only fetch keys they know about from a TXT record and ignore the rest. However, some debugging tools wish to fetch and display all keys. To do that, use the TXTRecordGetCount() and TXTRecordGetItemAtIndex() calls.

DNSServiceCreateDelegateConnection

Create a delegate connection to the daemon allowing efficient registration of multiple individual records.

DNSServiceSetDispatchQueue

Allows you to schedule a DNSServiceRef on a serial dispatch queue for receiving asynchronous callbacks.

TXTRecordContainsKey

Allows you to determine if a given TXT Record contains a specified key.

TXTRecordGetCount

Returns the number of keys stored in the TXT Record.

TXTRecordGetItemAtIndex

Allows you to retrieve a key name and value pointer, given an index into a TXT Record.

TXTRecordGetValuePtr

Allows you to retrieve the value for a given key from a TXT Record.

TXT Record Construction Functions

TXTRecordCreate

Creates a new empty TXTRecordRef referencing the specified storage.

TXTRecordDeallocate

Releases resources associated with a TXT record.

TXTRecordGetBytesPtr

Allows you to retrieve a pointer to the raw bytes within a TXTRecordRef.

TXTRecordGetLength

Allows you to determine the length of the raw bytes within a TXTRecordRef.

TXTRecordRemoveValue

Removes a key from a TXTRecordRef.

TXTRecordSetValue

Adds a key (optionally with value) to a TXTRecordRef.

Special Purpose Calls

DNSServiceCreateConnection

Creates a connection to the daemon, allowing efficient registration of multiple individual records.

DNSServiceReconfirmRecord

Instructs the daemon to verify the validity of a resource record that appears to be out of date (for example, because TCP connection to a service's target failed).

DNSServiceRegisterRecord

Registers an individual resource record on a connected DNSServiceRef.

PeerConnectionRelease

Releases P2P connection resources associated with the service instance.

Service Registration

DNSServiceAddRecord

Adds a record to a registered service.

DNSServiceRegister

Registers a service.

DNSServiceRemoveRecord

Removes a record previously added to a service record set via DNSServiceAddRecord, or deregister an record registered individually via DNSServiceRegisterRecord.

DNSServiceUpdateRecord

Updates a registered resource record.

Service Discovery

DNSServiceBrowse

Browses for available services.

Querying Individual Specific Records

DNSServiceQueryRecord

Query for an arbitrary DNS record.

NAT Port Mapping

DNSServiceNATPortMappingCreate

Requests a port mapping in the NAT gateway, which maps a port on the local machine to an external port on the NAT.

General Utility Functions

DNSServiceConstructFullName

Concatenates a three-part domain name (as returned by the above callbacks) into a properly-escaped full domain name.

Domain Enumeration

DNSServiceEnumerateDomains

Enumerates domains that are recommended for registration and browsing.

Callbacks

See the Overview section above for header-level documentation.

DNSServiceCreateConnection, DNSServiceRegisterRecord, DNSServiceReconfirmRecord (most applications will not use these)

DNSServiceGetAddrInfoReply

Callback for handling the results of a previous call to DNSServiceGetAddrInfo.

DNSServiceRegisterRecordReply

Callback for handling the results of a previous call to DNSServiceRegisterRecord.

DNSServiceRegisterReply

Handler for the results from a previous call to DNSServiceRegister.

DNSServiceBrowseReply

Callback for handling the results of previous calls to DNSServiceBrowse.

DNSServiceQueryRecordReply

Callback for handling the results of a previous call to DNSServiceQueryRecord.

DNSServiceNATPortMappingReply

Callback for handling the reply from a previous call to DNSServiceNATPortMappingReply.

DNSServiceDomainEnumReply

Callback for handling the results of a previous call to DNSServiceEnumerateDomains.

Data Types

See the Overview section above for header-level documentation.

TXTRecordRef

Opaque internal data type that represents a DNS-SD TXT record.

Constants

See the Overview section above for header-level documentation.