/usr/share/mozart/doc/contrib/node6.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>4 An Example of a Server Directory</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node5.html#chapter.compat"><< Prev</A></TD><TD><A href="index.html">- Up -</A></TD></TR></TABLE><DIV id="chapter.directory"><H1><A name="chapter.directory">4 An Example of a Server Directory</A></H1><H3 class="authors"><A href="http://www.sics.se/~andreas">Andreas Sundström</A></H3><P> This contribution is meant primarily to work as an example of how one can use the module <CODE>Discovery</CODE> and build a yellow pages service. The directory service consists out of three parts: a directory server, an interface to announce services, and a way to find announced services. </P><P> All services have descriptions. When a lookup is performed, a pattern is given to specify what to look for. The result of the lookup are services that have descriptions matching the pattern. Both descriptions and patterns are Oz records. </P><P> So what does it mean that a description <EM>match</EM> a pattern? All features in a pattern must be present in the description. If a field in the pattern has a value, then it must be either equal or match to a corresponding field in the description. For example, f(a:1 b:g(x:5 y:7) c:28 d:foo) does match f(c:28 b:g d:_), but not the other way around. </P><P> One could say that a pattern puts constraints on a matching description. Our form of pattern puts constraints on the label and features of the description. </P><DIV id="section.directory.module"><H2><A name="section.directory.module">4.1 The ExampleDirectory Module</A></H2><P> The module has three classes under features (<CODE>server</CODE>, <CODE>serviceProvider</CODE> and <CODE>client</CODE>), which corresponds to the three parts mentioned earlier. </P><P> The class <CODE>ExampleDirectory<SPAN class="keyword">.</SPAN>server</CODE> has following methods: </P><P> </P><DL><DT><CODE>init</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>init(port:</CODE><CODE><I>PortNr</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> useDefault<BR> expectedClientId:</CODE><CODE><I>ClientId</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">unit</SPAN> <BR> id:</CODE><CODE><I>ServerId</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> directory(kind:recordMatching))<BR> </CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>This method starts a directory server. The initial contact between a client (or service provider) and the server is made through the ip port <CODE><I>PortNr</I></CODE>. The default ip port number is <CODE>Discovery<SPAN class="keyword">.</SPAN>defaultPortNumber</CODE>. After the first contact has been performed, all subsequent interactions are done using Oz ports. </P><P> <CODE><I>ServerId</I></CODE> is a record explaining which type of directory server it is. </P><P> <CODE><I>ClientId</I></CODE> is a record used to specify which clients should be served. If a client id sent from a client (or service provider) matches <CODE><I>ClientId</I></CODE>, the client will be served. If the feature <CODE>expectedClientId</CODE> is not specified the server will serve every client requesting service. </P></DD><DT><CODE>close</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>close()<BR> </CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>Closes the operation of the server. </P></DD></DL><P> </P><P> The class <CODE>ExampleDirectory<SPAN class="keyword">.</SPAN>serviceProvider</CODE> has following methods: </P><P> </P><DL><DT><CODE>init</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>init(serverPort:</CODE><CODE><I>PortNr</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> useDefault<BR> id:</CODE><CODE><I>ClientId</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">unit</SPAN> <BR> expectedServerId:</CODE><CODE><I>ServerId</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> directory(kind:recordMatching) <BR> timeOut:</CODE><CODE><I>TimeOut</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> 1000)<BR> </CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>This method broadcasts to the ip port <CODE><I>PortNr</I></CODE> and waits for answers from servers that listen to it. The servers that answer and which id matches <CODE><I>ServerId</I></CODE> will be used by the other methods of this class. </P><P> When interacting with the servers, <CODE><I>ClientId</I></CODE> will be used as identification. The method will not consider answers received after <CODE><I>TimeOut</I></CODE> milliseconds has gone by. </P></DD><DT><CODE>add</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>add(description:</CODE><CODE><I>Desc</I></CODE><CODE> <BR> ticket:</CODE><CODE><I>Ticket</I></CODE><CODE> <BR> key:?</CODE><CODE><I>Key <= _</I></CODE><CODE>)<BR> </CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>This method announces a service with a description <CODE><I>Desc</I></CODE>. <CODE><I>Ticket</I></CODE> is a ticket to an Oz-entity that is used as an interface to the service. An Oz name that can be used to remove the service from the directories is returned. </P></DD><DT><CODE>remove</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>remove(key:Key)</CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>Tells the servers to remove a service with the key <CODE><I>Key</I></CODE>. </P></DD></DL><P> </P><P> The class <CODE>ExampleDirectory<SPAN class="keyword">.</SPAN>client</CODE> has following methods: </P><P> </P><DL><DT><CODE>init</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>init(serverPort:</CODE><CODE><I>PortNr</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> useDefault<BR> id:</CODE><CODE><I>ClientId</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">unit</SPAN> <BR> expectedServerId:</CODE><CODE><I>ServerId</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> directory(kind:recordMatching)<BR> timeOut:</CODE><CODE><I>TimeOut</I></CODE><CODE> <SPAN class="keyword"><=</SPAN> 1000)<BR> </CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>Similar to <CODE>ExampleDirectory<SPAN class="keyword">.</SPAN>serviceProvider</CODE>. </P></DD><DT><CODE>lookup</CODE> </DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>lookup(pattern:</CODE><CODE><I>Pattern</I></CODE><CODE> services:?</CODE><CODE><I>Services</I></CODE><CODE>)<BR> </CODE></BLOCKQUOTE><P> </P></BLOCKQUOTE></DD><DD><P>Asks servers for services that match the <CODE><I>Pattern</I></CODE>. A list of pairs is returned. Those pairs consist of a service description and its ticket. </P></DD></DL><P> </P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node5.html#chapter.compat"><< Prev</A></TD><TD><A href="index.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A> and <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|