1nameserv(n) Name service facility nameserv(n)
2
3
4
5______________________________________________________________________________
6
8 nameserv - Name service facility, Client
9
11 package require Tcl 8.4
12
13 package require nameserv ?0.4.2?
14
15 package require comm
16
17 package require logger
18
19 ::nameserv::bind name data
20
21 ::nameserv::release
22
23 ::nameserv::search ?-async|-continuous? ?pattern?
24
25 ::nameserv::protocol
26
27 ::nameserv::server_protocol
28
29 ::nameserv::server_features
30
31 ::nameserv::cget -option
32
33 ::nameserv::configure
34
35 ::nameserv::configure -option
36
37 ::nameserv::configure -option value...
38
39 $result destroy
40
41 $result filled
42
43 $result get name
44
45 $result names
46
47 $result size
48
49 $result getall ?pattern?
50
51______________________________________________________________________________
52
54 Please read Name service facility, introduction first.
55
56 This package provides a client for the name service facility imple‐
57 mented by the package nameserv::server.
58
59 This service is built in top of and for the package comm. It has noth‐
60 ing to do with the Internet's Domain Name System. If the reader is
61 looking for a package dealing with that please see Tcllib's packages
62 dns and resolv.
63
65 The package exports eight commands, as specified below:
66
67 ::nameserv::bind name data
68 The caller of this command registers the given name as its name
69 in the configured name service, and additionally associates a
70 piece of data with it. The service does nothing with this infor‐
71 mation beyond storing it and delivering it as part of search re‐
72 sults. The meaning is entirely up to the applications using the
73 name service.
74
75 A generally useful choice would for example be an identifier for
76 a communication endpoint managed by the package comm. Anybody
77 retrieving the name becomes immediately able to talk to this
78 endpoint, i.e. the registering application.
79
80 Of further importance is that a caller can register itself under
81 more than one name, and each name can have its own piece of
82 data.
83
84 Note that the name service, and thwerefore this command, will
85 throw an error if the chosen name is already registered.
86
87 ::nameserv::release
88 Invoking this command releases all names (and their data) regis‐
89 tered by all previous calls to ::nameserv::bind of this client.
90 Note that the name service will run this command implicitly when
91 it loses the connection to this client.
92
93 ::nameserv::search ?-async|-continuous? ?pattern?
94 This command searches the name service for all registered names
95 matching the specified glob-pattern. If not specified the pat‐
96 tern defaults to *, matching everything. The result of the com‐
97 mand is a dictionary mapping the matching names to the data as‐
98 sociated with them at bind-time.
99
100 If either option -async or -continuous were specified the result
101 of this command changes and becomes the Tcl command of an object
102 holding the actual result. These two options are supported if
103 and only if the service the client is connected to supports the
104 protocol feature Search/Continuous.
105
106 For -async the result object is asynchronously filled with the
107 entries matching the pattern at the time of the search and then
108 not modified any more. The option -continuous extends this be‐
109 haviour by additionally continuously monitoring the service for
110 the addition and removal of entries which match the pattern, and
111 updating the object's contents appropriately.
112
113 Note that the caller is responsible for configuring the object
114 with a callback for proper notification when the current result
115 (or further changes) arrive.
116
117 For more information about this object see section ASYNCHRONOUS
118 AND CONTINUOUS SEARCHES.
119
120 ::nameserv::protocol
121 This command returns the highest version of the name service
122 protocol supported by the package.
123
124 ::nameserv::server_protocol
125 This command returns the highest version of the name service
126 protocol supported by the name service the client is currently
127 connected to.
128
129 ::nameserv::server_features
130 This command returns a list containing the names of the features
131 of the name service protocol which are supported by the name
132 service the client is currently connected to.
133
134 ::nameserv::cget -option
135 This command returns the currently configured value for the
136 specified -option. The list of supported options and their mean‐
137 ing can be found in section OPTIONS.
138
139 ::nameserv::configure
140 In this form the command returns a dictionary of all supported
141 options, and their current values. The list of supported options
142 and their meaning can be found in section OPTIONS.
143
144 ::nameserv::configure -option
145 In this form the command is an alias for "::nameserv::cget -op‐
146 tion". The list of supported options and their meaning can be
147 found in section OPTIONS.
148
149 ::nameserv::configure -option value...
150 In this form the command is used to configure one or more of the
151 supported options. At least one option has to be specified, and
152 each option is followed by its new value. The list of supported
153 options and their meaning can be found in section OPTIONS.
154
155 This form can be used only as long as the client has not con‐
156 tacted the name service yet. After contact has been made recon‐
157 figuration is not possible anymore. This means that this form of
158 the command is for the initalization of the client before it
159 use. The command forcing a contact with the name service are
160
161 bind
162
163 release
164
165 search
166
167 server_protocol
168
169 server_features
170
172 The client automatically connects to the service when one of the com‐
173 mands below is run for the first time, or whenever one of the commands
174 is run after the connection was lost, when it was lost.
175
176 bind
177
178 release
179
180 search
181
182 server_protocol
183
184 server_features
185
186 Since version 0.2 of the client it will generate an event when the con‐
187 nection is lost, allowing higher layers to perform additional actions.
188 This is done via the support package uevent. This and all other name
189 service related packages hereby reserve the uevent-tag nameserv. All
190 their events will be posted to that tag.
191
193 This package generates only one event, lost-connection. The detail in‐
194 formation provided to that event is a Tcl dictionary. The only key con‐
195 tained in the dictionnary is reason, and its value will be a string de‐
196 scribing why the connection was lost. This string is supplied by the
197 underlying communication package, i.e. comm.
198
200 The options supported by the client are for the specification of which
201 name service to contact, i.e. of the location of the name service.
202 They are:
203
204 -host name|ipaddress
205 This option specifies the host name service to contact is run‐
206 ning on, either by name, or by ipaddress. The initial default is
207 localhost, i.e. it is expected to contact a name service running
208 on the same host as the application using this package.
209
210 -port number
211 This option specifies the port the name service to contact is
212 listening on. It has to be a positive integer number (> 0) not
213 greater than 65536 (unsigned short). The initial default is the
214 number returned by the command ::nameserv::common::port, as pro‐
215 vided by the package ::nameserv::common.
216
218 Asynchronous and continuous searches are invoked by using either option
219 -async or -continuous as argument to the command ::nameserv::search.
220
221 Note that these two options are supported if and only if the service
222 the client is connected to supports the protocol feature Search/Contin‐
223 uous. The service provided by the package ::nameserv::server does this
224 since version 0.3.
225
226 For such searches the result of the search command is the Tcl command
227 of an object holding the actual result. The API provided by these ob‐
228 jects is:
229
230 Options:
231
232 -command command_prefix
233 This option has to be set if a user of the result object
234 wishes to get asynchronous notifications when the search
235 result or changes to it arrive.
236
237 Note that while it is possible to poll for the arrival of
238 the initial search result via the method filled, and for
239 subsequent changes by comparing the output of method
240 getall against a saved copy, this is not the recommended
241 behaviour. Setting the -command callback and processing
242 the notifications as they arrive is much more efficient.
243
244 The command_prefix is called with two arguments, the type
245 of change, and the data of the change. The type is either
246 add or remove, indicating new data, or deleted data, re‐
247 spectively. The data of the change is always a dictio‐
248 nary listing the added/removed names and their associated
249 data.
250
251 The first change reported for a search is always the set
252 of matching entries at the time of the search.
253
254 Methods:
255
256 $result destroy
257 Destroys the object and cancels any continuous monitoring
258 of the service the object may have had active.
259
260 $result filled
261 The result is a boolean value indicating whether the
262 search result has already arrived (True), or not (False).
263
264 $result get name
265 Returns the data associated with the given name at bind-
266 time.
267
268 $result names
269 Returns a list containing all names known to the object
270 at the time of the invokation.
271
272 $result size
273 Returns an integer value specifying the size of the re‐
274 sult at the time of the invokation.
275
276 $result getall ?pattern?
277 Returns a dictionary containing the search result at the
278 time of the invokation, mapping the matching names to the
279 data associated with them at bind-time.
280
282 0.3.1 Fixed SF Bug 1954771.
283
284 0.3 Extended the client with the ability to perform asynchronous and
285 continuous searches.
286
287 0.2 Extended the client with the ability to generate events when it
288 loses its connection to the name service. Based on package
289 uevent.
290
291 0.1 Initial implementation of the client.
292
294 This document, and the package it describes, will undoubtedly contain
295 bugs and other problems. Please report such in the category nameserv
296 of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
297 also report any ideas for enhancements you may have for either package
298 and/or documentation.
299
300 When proposing code changes, please provide unified diffs, i.e the out‐
301 put of diff -u.
302
303 Note further that attachments are strongly preferred over inlined
304 patches. Attachments can be made by going to the Edit form of the
305 ticket immediately after its creation, and then using the left-most
306 button in the secondary navigation bar.
307
309 nameserv::common(n), nameserv::server(n)
310
312 client, name service
313
315 Networking
316
318 Copyright (c) 2007-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net>
319
320
321
322
323tcllib 0.4.2 nameserv(n)