/usr/share/mozart/doc/apptut/node12.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>9 Introduction</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="node11.html">- Up -</A></TD><TD><A href="node13.html#chapter.client.server.db">Next >></A></TD></TR></TABLE><DIV id="chapter.client.server.intro"><H1><A name="chapter.client.server.intro">9 Introduction</A></H1><P>A large fraction of client/server applications fall in the same simple pattern: there is a basic service encapsulated as an object and we wish to allow remote clients to send requests to this object, to be processed at the server host.</P><P>The basic idea is to make available to clients a procedure that forwards a client's request to the live server object. This forwarding is effected by means of a port. The forwarding procedure itself is made available indirectly through a ticket. This ticket is placed in a file that is accessible through a URL.</P><H2><A name="label35">9.1 A Generic Server <CODE>server.oz</CODE></A></H2><P>It is straightforward to write a generic server module that exports a <CODE><I>Start</I></CODE> procedure. The latter takes 2 arguments: <CODE><I>Proc</I></CODE> the object or procedure implementing the service and <CODE><I>File</I></CODE> the name of the file where the ticket should be saved. <CODE><I>Proc</I></CODE> is intended to be applied to messages forwarded by clients.</P><P>The forwarding procedure <CODE><I>Proxy</I></CODE> takes the clients message <CODE><I>Msg</I></CODE> and sends <CODE>request(</CODE><CODE><I>Msg</I></CODE><CODE> </CODE><CODE><I>OK</I></CODE><CODE>)</CODE> to the server's port. The server binds <CODE><I>OK</I></CODE> to true or false depending on whether the <CODE><I>Msg</I></CODE> is processed successfully or an exception is raised. </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR><SPAN class="keyword">import</SPAN> Connection Pickle<BR><SPAN class="keyword">export</SPAN> Start<BR><SPAN class="keyword">define</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Start</SPAN> Proc File}<BR> Requests P = {NewPort Requests} Ticket<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Proxy</SPAN> Msg}<BR> <SPAN class="keyword">if</SPAN> {Port<SPAN class="keyword">.</SPAN>send P request(Msg $)} <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> <SPAN class="keyword">raise</SPAN> remoteError <SPAN class="keyword">end</SPAN> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> {New Connection<SPAN class="keyword">.</SPAN>gate init(Proxy Ticket) _}<BR> {Pickle<SPAN class="keyword">.</SPAN>save Ticket File}<BR> {ForAll Requests<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> R}<BR> <SPAN class="keyword">case</SPAN> R <SPAN class="keyword">of</SPAN> request(Msg OK) <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">try</SPAN> {Proc Msg} OK=<SPAN class="keyword">true</SPAN> <SPAN class="keyword">catch</SPAN> _ <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">try</SPAN> OK=<SPAN class="keyword">false</SPAN> <SPAN class="keyword">catch</SPAN> _ <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">else</SPAN> <SPAN class="keyword">skip</SPAN> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P> The server functor will be used as an import in subsequent examples and can be compiled as follows: </P><BLOCKQUOTE class="code"><CODE>ozc -c server.oz</CODE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node11.html">- Up -</A></TD><TD><A href="node13.html#chapter.client.server.db">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A> and <A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|