1DNSServiceBrowse(3DNSD_NSSD)Service Discovery Library FuncDtNiSoSnesrviceBrowse(3DNS_SD)
2
3
4
6 DNSServiceBrowse - browse service instances with DNS
7
9 cc [ flag ... ] file ... -ldns_sd [ library ... ]
10 #include <dns_sd.h>
11
12 DNSServiceErrorType DNSServiceBrowse(DNSServiceRef *sdRef,
13 DNSServiceFlags flags, uint32_t interfaceIndex,
14 const char *regtype, const char *domain,
15 DNSServiceServiceBrowseReply callBack, void *context);
16
17
18 typedef void(*DNSServiceBrowseReply)(DNSServiceRef sdRef,
19 DNSServiceFlags flags, uint32_t interfaceIndex,
20 DNSServiceErrorType errorCode, const char *serviceName,
21 const char *regtype, const char *replyDomain,
22 void *context);
23
24
26 The DNSServiceBrowse() function is used to browse for service instances
27 of a particular service and protocol type. The sdRef argument points to
28 an uninitialized DNSServiceRef. If the call to DNSServiceBrowse suc‐
29 ceeds sdRef is initialized. The flags argument to DNSServiceBrowse() is
30 currently unused and reserved for future use. A nonzero value to inter‐
31 faceIndex indicates DNSServiceBrowse() should do a browse on all inter‐
32 faces. Most applications will use an interfaceIndex value of 0 to per‐
33 form a browse on all interfaces. See the section "Constants for speci‐
34 fying an interface index" in <dns_sd.h> for more details.
35
36
37 The callback function is invoked for every service instance found
38 matching the service type and protocol. The callback argument points to
39 a function of type DNSServiceBrowseReply listed above. The DNSService‐
40 Browse() call returns browse results asynchronously. The service browse
41 call can be terminated by applications with a call to DNSSer‐
42 viceRefDeallocate().
43
44
45 The regtype parameter is used to specify the service type and protocol
46 (e.g. _ftp._tcp). The protocol type must be TCP or UDP. The domain
47 argument to DNSServiceBrowse() specifies the domain on which to browse
48 for services. Most applications will not specify a domain and will per‐
49 form a browse on the default domain(s). The context argument can be
50 NULL and points to a value passed to the callback function.
51
52
53 The sdRef argument passed to the callback function is initialized by
54 DNSServiceBrowse() call. The possible values passed to flags in the
55 callback function are: kDNSServiceFlagsMoreComing and kDNSService‐
56 FlagsAdd. The kDNSServiceFlagsMoreComing value indicates to a callback
57 that at least one more result is immediately available. The kDNSSer‐
58 viceFlagsAdd value indicates that a service instance was found. The
59 errorCode argument will be kDNSServiceErr_NoError on success. Other‐
60 wise, failure is indicated. The discovered service name is returned to
61 the callback via the serviceName argument. The regtype argument in the
62 callback holds the service type of the found service instance. The dis‐
63 covered service type can be different from the requested service type
64 in the browse request when the discovered service type has subtypes.
65 The domain argument to the callback holds the domain name of the dis‐
66 covered service instance. The service type and the domain name must be
67 stored and passed along with the service name to resolve a service
68 instance using DNSServiceResolve().
69
71 The DNSServiceBrowse function returns kDNSServiceErr_NoError on suc‐
72 cess. Otherwise, an error code defined in <dns_sd.h> is returned to
73 indicate an error has occurred. When an error is returned by DNSSer‐
74 viceBrowse, the callback function is not invoked and the DNSServiceRef
75 argument is not initialized.
76
78 See attributes(5) for description of the following attributes:
79
80
81
82
83 ┌─────────────────────────────┬─────────────────────────────┐
84 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
85 ├─────────────────────────────┼─────────────────────────────┤
86 │Interface Stability │Committed │
87 ├─────────────────────────────┼─────────────────────────────┤
88 │MT-Level │Safe │
89 └─────────────────────────────┴─────────────────────────────┘
90
92 DNSServiceRefDeallocate(3DNS_SD), DNSServiceResolve(3DNS_SD),
93 attributes(5)
94
95
96
97SunOS 5.11 20 Aug 2007 DNSServiceBrowse(3DNS_SD)