nameserv - Name service facility, Client
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:
The caller of this command registers the given name as its name in the configured name service, and additionally associates a piece of 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.
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.
Invoking this command releases all names (and their data) registered by all previous calls to ::nameserv::bind of this client. Note that the name service will run this command implicitly when it loses the connection to this client.
This command searches the name service for all registered names matching the specified glob-pattern. If not specified the pattern defaults to *, matching everything. The result of the command is a dictionary mapping the matching names to the data associated with them at bind-time.
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 command returns the highest version of the name service protocol supported by the package.
This command returns the highest version of the name service protocol supported by the name service the client is currently connected to.
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.
This command returns the currently configured value for the specified -option. The list of supported options and their meaning can be found in section OPTIONS.
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 OPTIONS.
In this form the command is an alias for "::nameserv::cget -option]". The list of supported options and their meaning can be found in section OPTIONS.
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 OPTIONS.
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:
Destroys the object and cancels any continuous monitoring of the service the object may have had active.
The result is a boolean value indicating whether the search result has already arrived (True), or not (False).
Returns the data associated with the given name at bind-time.
Returns a list containing all names known to the object at the time of the invokation.
Returns an integer value specifying the size of the result at the time of the invokation.
Returns a dictionary containing the search result at the time of the invokation, mapping the matching names to the data associated with them at bind-time.
Fixed SF Bug 1954771.
Extended the client with the ability to perform asynchronous and continuous searches.
Extended the client with the ability to generate events when it loses its connection to the name service. Based on package uevent.
Initial implementation of the client.
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. Please also report any ideas for enhancements you may have for either package and/or documentation.
Networking
Copyright © 2007-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net>