1DNSServiceRegister(3DDNNSS_SSDe)rvice Discovery Library FuDnNcStSieornvsiceRegister(3DNS_SD)
2
3
4

NAME

6       DNSServiceRegister - register service with DNS
7

SYNOPSIS

9       cc [ flag ... ] file ... -ldns_sd [ library ... ]
10       #include <dns_sd.h>
11
12       DNSServiceErrorType DNSServiceRegister(DNSServiceRef *sdRef,
13            DNSServiceFlags flags, uint32_t interfaceIndex,
14            const char *name, const char *regtype,
15            const char *domain, const char *host,
16            uint16_t port, uint16_t *txtLen, const void *txtRecord
17            DNSServiceServiceRegisterReply callBack
18            void *context);
19
20
21       typedef void(*DNSServiceRegisterReply)(DNSServiceRef sdRef,
22            DNSServiceFlags flags, DNSServiceErrorType errorCode,
23            const char *name, const char *regtype,
24            const char *domain, void *context);
25
26

DESCRIPTION

28       The  DNSServiceRegister function is used by clients to advertise a ser‐
29       vice that uses DNS. The service is registered with multicast DNS if the
30       domain  name is .local or the interface requested is local only. Other‐
31       wise, the service  registration  is  attempted  with  the  unicast  DNS
32       server.  The  callback  argument  should  point  to  a function of type
33       DNSServiceRegisterReply listed above.
34
35
36       The sdRef parameter points to an uninitialized DNSServiceRef  instance.
37       If  the  DNSServiceRegister()  call  succeeds, sdRef is initialized and
38       kDNSServiceErr_NoError is returned. The  service  registration  remains
39       active until the client terminates the registration by passing the ini‐
40       tialized sdRef to DNSServiceRefDeallocate().  The  interfaceIndex  when
41       non-zero  specifies the interface on which the service should be regis‐
42       tered. Most applications pass 0 to register the service on  all  inter‐
43       faces. See the section "Constants for specifying an interface index" in
44       <dns_sd.h> for more details. The flags parameter determines the  renam‐
45       ing  behavior  on  a service name conflict. Most applications pass 0 to
46       allow auto-rename of the service name  in  case  of  a  name  conflict.
47       Applications  can pass the flag kDNSServiceFlagsNoAutoRename defined in
48       <dns_sd.h> to disable auto-rename.
49
50
51       The regtype indicates the service type followed by the protocol,  sepa‐
52       rated  by  a dot, for example "_ftp._tcp.". The service type must be an
53       underscore that is followed by 1 to 14 characters that can be  letters,
54       digits,  or  hyphens.  The transport protocol must be _tcp or _udp. New
55       service types should be  registered  at  http://www.dns-sd.org/Service
56       Types.html.  The  domain parameter specifies the domain on which a ser‐
57       vice is advertised. Most applications leave the domain  parameter  NULL
58       to  register  the service in default domains. The host parameter speci‐
59       fies the SRV target host name. Most applications  do  not  specify  the
60       host  parameter value. Instead, the default host name of the machine is
61       used. The port value on which the service accepts connections  must  be
62       passed in network byte order. A value of 0 for a port is passed to reg‐
63       ister placeholder services. Placeholder services  are  not  found  when
64       browsing,  but  other clients cannot register with the same name as the
65       placeholder service.
66
67
68       The txtLen parameter specifies the length of the  passed  txtRecord  in
69       bytes.  The  value  must  be  zero if the txtRecord passed is NULL. The
70       txtRecord points to the TXT record rdata. A non-NULL txtRecord must  be
71       a  properly  formatted  DNSTXT record. For more details see the DNSSer‐
72       viceRegister call defined in <dns_sd.h>. The callback  argument  points
73       to a function to be called when registration completes or when the call
74       asynchronously fails. The client can pass NULL for the callback and not
75       be  notified  of  the  registration results or asynchronous errors. The
76       client may not pass the NoAutoRename flag if the callback is NULL.  The
77       client  can unregister the service at any time via DNSServiceRefDeallo‐
78       cate().
79
80
81       The callback function argument sdRef is initialized by DNSServiceRegis‐
82       ter().  The flags argument in the callback function is currently unused
83       and reserved for future use. The error code returned to the callback is
84       kDNSServiceErr_NoError  on success. Otherwise, an error code defined in
85       <dns_sd.h> is returned to indicate an error condition such  as  a  name
86       conflict  in kDNSServiceFlagsNoAutoRename mode. The name argument holds
87       the registered service name and the regtype argument is the  registered
88       service  type  passed  to  DNSServiceRegister().  The  domain  argument
89       returned in the callback indicates the domain on which the service  was
90       registered.
91

RETURN VALUES

93       The  DNSServiceRegister function returns kDNSServiceErr_NoError on suc‐
94       cess. Otherwise, an error code defined in <dns_sd.h> is returned.  Upon
95       registration,  any  subsequent asynchronous errors are delivered to the
96       callback.
97

ATTRIBUTES

99       See attributes(5) for description of the following attributes:
100
101
102
103
104       ┌─────────────────────────────┬─────────────────────────────┐
105       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
106       ├─────────────────────────────┼─────────────────────────────┤
107       │Interface Stability          │Committed                    │
108       ├─────────────────────────────┼─────────────────────────────┤
109       │MT-Level                     │Safe                         │
110       └─────────────────────────────┴─────────────────────────────┘
111

SEE ALSO

113       DNSServiceRefDeallocate(3DNS_SD), attributes(5)
114
115
116
117SunOS 5.11                        20 Aug 2007      DNSServiceRegister(3DNS_SD)
Impressum