nameserv(n) | Name service facility | nameserv(n) |
nameserv - Name service facility, Client
package require Tcl 8.4
package require nameserv ?0.4.2?
package require comm
package require logger
::nameserv::bind name data
::nameserv::release
::nameserv::search ?-async|-continuous? ?pattern?
::nameserv::protocol
::nameserv::server_protocol
::nameserv::server_features
::nameserv::cget -option
::nameserv::configure
::nameserv::configure -option
::nameserv::configure -option value...
$result destroy
$result filled
$result get name
$result names
$result size
$result getall ?pattern?
Please read Name service facility, introduction first.
This package provides a client for the name service facility implemented by the package nameserv::server.
This service is built in top of and for the 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 dns and resolv.
The package exports eight commands, as specified below:
A generally useful choice would for example be an identifier for a communication endpoint managed by the package comm. Anybody retrieving the name becomes immediately able to talk to this endpoint, i.e. the registering application.
Of further importance is that a caller can register itself under more than one name, and each name can have its own piece of data.
Note that the name service, and thwerefore this command, will throw an error if the chosen name is already registered.
If either option -async or -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 Search/Continuous.
For -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 -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.
Note that the caller is responsible for configuring the object with a callback for proper notification when the current result (or further changes) arrive.
For more information about this object see section ASYNCHRONOUS AND CONTINUOUS SEARCHES.
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
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.
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 uevent. This and all other name service related packages hereby reserve the uevent-tag nameserv. All their events will be posted to that tag.
This package generates only one event, lost-connection. The detail information provided to that event is a Tcl dictionary. The only key contained in the dictionnary is 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. comm.
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:
Asynchronous and continuous searches are invoked by using either option -async or -continuous as argument to the command ::nameserv::search.
Note that these two options are supported if and only if the service the client is connected to supports the protocol feature Search/Continuous. The service provided by the package ::nameserv::server does this since version 0.3.
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:
Note that while it is possible to poll for the arrival of the initial search result via the method filled, and for subsequent changes by comparing the output of method getall against a saved copy, this is not the recommended behaviour. Setting the -command callback and processing the notifications as they arrive is much more efficient.
The command_prefix is called with two arguments, the type of change, and the data of the change. The type is either add or 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.
The first change reported for a search is always the set of matching entries at the time of the search.
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category nameserv of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation.
nameserv::common(n), nameserv::server(n)
client, name service
Networking
Copyright (c) 2007-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net>
0.4.2 | nns |