/usr/share/mozart/doc/op/node13.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.3 Accepting Multiple Connections</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="node12.html#section.sockets.stream"><< Prev</A></TD><TD><A href="node10.html">- Up -</A></TD><TD><A href="node14.html#section.sockets.datagram">Next >></A></TD></TR></TABLE><DIV id="section.sockets.accept"><H2><A name="section.sockets.accept">5.3 Accepting Multiple Connections</A></H2><P>A frequently occuring situation is to have a single server with a port number known to several clients and that all these clients want to connect to that server. For this purpose sockets have the possibility to accept more than a single connection. </P><P>The first step is to create the server socket <CODE>S</CODE> with a port number <CODE>P</CODE>: </P><DL class="anonymous"><DD class="code"><CODE>S={New Open<SPAN class="keyword">.</SPAN>socket init}<BR>P={S bind(port:$)}<BR>{S listen}</CODE></DD></DL><P> The clients can connect later to this socket with the port number <CODE>P</CODE>.</P><P> </P><DIV class="program" id="fig.setup.server"><HR><P><A name="fig.setup.server"></A></P></DIV><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">class</SPAN> <SPAN class="type">Accepted</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Open.socket</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">report</SPAN>(H P)<BR> {Browse read(host:H port:P read:{<SPAN class="keyword">self</SPAN> read(list:$)})}<BR> {<SPAN class="keyword">self</SPAN> report(H P)}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN> <BR> <BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Accept</SPAN>}<BR> H P A<BR><SPAN class="keyword">in</SPAN> <BR> {S accept(acceptClass:Accepted<BR> host:?H port:?P accepted:?A)}<BR> <SPAN class="keyword">thread</SPAN> <BR> {A report(H P)} <BR> <SPAN class="keyword">end</SPAN> <BR> {Accept}<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><DIV class="program"><P class="caption"><STRONG>Program 5.1:</STRONG> Accepting multiple connections.</P><HR></DIV><P> </P><P>How to set up the server is shown in <A href="node13.html#fig.setup.server">Program 5.1</A>. The procedure <CODE>Accept</CODE> waits until the server socket <CODE>S</CODE> accepts a connection. When a connection is accepted, the variable <CODE>A</CODE> is bound to a newly created object. The object <CODE>A</CODE> is created from the class <CODE>Accepted</CODE>, this is specified by the feature <CODE>acceptClass</CODE>. The newly created object is already connected: Applying the object to the message <CODE>report(H P)</CODE> waits that on the accepted connection data arrives. </P><P>The loop to accept connections is started by applying the procedure <CODE>Accept</CODE>: </P><DL class="anonymous"><DD class="code"><CODE>{Accept}</CODE></DD></DL><P> </P><P>Let us assume that we have two clients <CODE>C1</CODE> and <CODE>C2</CODE> that need to connect to the socket with port number <CODE><I>P</I></CODE>: </P><DL class="anonymous"><DD class="code"><CODE>C1={New Open<SPAN class="keyword">.</SPAN>socket client(port:P)} <BR>C2={New Open<SPAN class="keyword">.</SPAN>socket client(port:P)}</CODE></DD></DL><P> </P><P>After the clients are connected, sending data from the clients is as usual: </P><DL class="anonymous"><DD class="code"><CODE>{C1 write(vs:<SPAN class="string">'hello from C1'</SPAN>)}</CODE></DD></DL><P> </P><P>As soon as the socket object created by the procedure <CODE>Accept</CODE> receives the data sent from a client, the data appears in the Browser.</P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node12.html#section.sockets.stream"><< Prev</A></TD><TD><A href="node10.html">- Up -</A></TD><TD><A href="node14.html#section.sockets.datagram">Next >></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>
|