/usr/share/mozart/doc/op/node15.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>5.5 Example: Are We Working Right Now?</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="node14.html#section.sockets.datagram"><< Prev</A></TD><TD><A href="node10.html">- Up -</A></TD></TR></TABLE><DIV id="section.sockets.finger"><H2><A name="section.sockets.finger">5.5 Example: Are We Working Right Now?</A></H2><P>As an example, we show how to use the <CODE>finger</CODE> service from Oz. Services<A name="label145"></A> are programs running on a host, where communication is provided by a socket connection. A well known example is the <CODE>finger</CODE> <A name="label146"></A> service. </P><P>Services use the Internet domain, thus for connecting to them we need the name of the host computer (i. e.its Internet address) and the port of the socket. For this reason there is the procedure <CODE>OS<SPAN class="keyword">.</SPAN>getServByName</CODE><A name="label147"></A> (see <A href="../system/node56.html#chapter.os">Chapter 21 of ``System Modules''</A>) which gives the port of the socket on which the service is available. Feeding </P><DL class="anonymous"><DD class="code"><CODE>FingerPort={OS<SPAN class="keyword">.</SPAN>getServByName finger tcp}</CODE></DD></DL><P> binds <CODE>FingerPort</CODE> to the port number of the service. </P><P>Note that one has to specify the protocol<A name="label148"></A> the service uses, here the TCP protocol<A name="label149"></A> (as specified by the virtual string <CODE>tcp</CODE>). The port number of a service is unique for all computers, so this number does not depend on your localhost. </P><P>To get the information from this service we have to connect to the finger service. If you want to know whether the author is working right now, then you can connect to one of our computers with the Internet address <CODE>wallaby<SPAN class="keyword">.</SPAN>ps<SPAN class="keyword">.</SPAN>uni<SPAN class="keyword">-</SPAN>sb<SPAN class="keyword">.</SPAN>de</CODE> on the <CODE>FingerPort</CODE>. This is done by feeding the code shown in Program <A href="node15.html#prog.finger">Program 5.2</A>. </P><P></P><DIV class="program" id="prog.finger"><HR><P><A name="prog.finger"></A></P><A name="label150"></A></DIV><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">class</SPAN> <SPAN class="type">FingerClient</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Open.socket</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getInfo</SPAN>($)<BR> Is Ir <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> {<SPAN class="keyword">self</SPAN> read(list:Is tail:Ir len:$)}<SPAN class="keyword">==</SPAN>0 <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">else</SPAN> {<SPAN class="keyword">self</SPAN> getInfo(Ir)} Is<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN> <BR>FC = {New FingerClient client(host:<SPAN class="string">'wallaby.ps.uni-sb.de'</SPAN> <BR> port:FingerPort)}</CODE></DD></DL><DIV class="program"><P class="caption"><STRONG>Program 5.2:</STRONG> The finger client <CODE>FC</CODE>.</P><HR></DIV><P></P><P>For discovering whether the author is logged in, you have to send his username (in this example <CODE>schulte</CODE>) followed by a newline to the service, and then receive the information: </P><DL class="anonymous"><DD class="code"><CODE>{FC write(vs:<SPAN class="string">'schulte\n'</SPAN>)}<BR>{Browse {FC getInfo($)}}</CODE></DD></DL><P> </P><P>For receiving the information we use the method <CODE>getInfo</CODE> which reads the entire information from the socket until it is closed (the finger service closes the connection automatically after sending its information).</P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node14.html#section.sockets.datagram"><< Prev</A></TD><TD><A href="node10.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><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>
|