This file is indexed.

/usr/share/mozart/doc/op/node14.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.4 Datagram Sockets</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="node13.html#section.sockets.accept">&lt;&lt; Prev</A></TD><TD><A href="node10.html">- Up -</A></TD><TD><A href="node15.html#section.sockets.finger">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.sockets.datagram"><H2><A name="section.sockets.datagram">5.4 Datagram Sockets</A></H2><P>Datagram sockets are for connectionless use. This implies that there is no distinction between server and client. The basic patterns of use are as follows. </P><P></P><H3><A name="label128">5.4.1 Initialization</A></H3><P>First we create and initialize two socket objects <CODE>S</CODE> and <CODE>T</CODE> with the type <CODE>datagram</CODE>: </P><DL class="anonymous"><DD class="code"><CODE>S={New&nbsp;Open<SPAN class="keyword">.</SPAN>socket&nbsp;init(type:datagram)}<BR>T={New&nbsp;Open<SPAN class="keyword">.</SPAN>socket&nbsp;init(type:datagram)}</CODE></DD></DL><P> <A name="label130"></A> </P><P>Both sockets can be named in the Internet domain as follows: </P><DL class="anonymous"><DD class="code"><CODE>SPN={S&nbsp;bind(port:$)}<BR>TPN={T&nbsp;bind(port:$)}</CODE></DD></DL><P> <A name="label132"></A></P><H3><A name="label133">5.4.2 Exchanging Data</A></H3><P>To send the virtual string <CODE><SPAN class="string">'really&nbsp;'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">&quot;great&quot;</SPAN></CODE> from socket <CODE>S</CODE> to socket <CODE>T</CODE>, we feed </P><DL class="anonymous"><DD class="code"><CODE>{S&nbsp;send(vs:<SPAN class="string">'really&nbsp;'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">&quot;great&quot;</SPAN>&nbsp;port:TPN)}</CODE></DD></DL><P> <A name="label135"></A> </P><P>Data can be received as follows: </P><DL class="anonymous"><DD class="code"><CODE>{T&nbsp;receive(list:?Is&nbsp;port:?P)}<BR>{Browse&nbsp;Is<SPAN class="keyword">#</SPAN><SPAN class="string">'&nbsp;from:&nbsp;'</SPAN><SPAN class="keyword">#</SPAN>P}</CODE></DD></DL><P> <A name="label137"></A> and <CODE>Is</CODE> is bound to the string <CODE><SPAN class="string">&quot;really&nbsp;great&quot;</SPAN></CODE> and <CODE>P</CODE> to the port number <CODE>SPN</CODE>. The roles of sender and receiver may be toggled as you like. </P><P>To send to a socket on a different computer, the hostname of the computer can be specified. For example, </P><BLOCKQUOTE class="code"><CODE>{S&nbsp;send(vs:<SPAN class="string">'donald'</SPAN>&nbsp;host:<SPAN class="string">'duck.somewhere'</SPAN>&nbsp;port:4711)}</CODE></BLOCKQUOTE><P> would send <CODE><SPAN class="string">'donald'</SPAN></CODE> to the socket with port number <CODE>4711</CODE> on the computer <CODE>duck<SPAN class="keyword">.</SPAN>somewhere</CODE>. Similarly, by using the field <CODE>host</CODE> for the <CODE>receive</CODE> method the sending computer can be found out.</P><H3><A name="label138">5.4.3 Peer</A></H3><P>An additional feature of the datagram socket is the ability to declare a socket as <A name="label139"></A><EM>peer</EM> <A name="label140"></A>. Suppose we want to declare socket <CODE>S</CODE> as a peer of socket <CODE>T</CODE>. This is done by </P><BLOCKQUOTE class="code"><CODE>{S&nbsp;connect(port:TPN)}</CODE></BLOCKQUOTE><P> <A name="label142"></A> </P><P>Now any message sent from socket <CODE>S</CODE> is received by socket <CODE>T</CODE>. Furthermore, it suffices to specify just the data to be sent. Hence </P><BLOCKQUOTE class="code"><CODE>{S&nbsp;send(vs:<SPAN class="string">&quot;really&nbsp;great&quot;</SPAN>)}</CODE></BLOCKQUOTE><P> <A name="label144"></A> has the same effect as the previous example. As an additional effect, only data sent by socket <CODE>T</CODE> is received at socket <CODE>S</CODE>. After a peer has been assigned, you can even use the methods <CODE>read</CODE> and <CODE>write</CODE>. </P><P>Disconnecting is the same as for stream sockets. </P><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node13.html#section.sockets.accept">&lt;&lt; Prev</A></TD><TD><A href="node10.html">- Up -</A></TD><TD><A href="node15.html#section.sockets.finger">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>