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