The package implements new kind of ⪆ input-output streams, called
input-output TCP streams. Such streams are based on the functionality
for the TCP/IP protocol usage provided by the ⪆ package &IO;, and
may constitute an independent interest for ⪆ users.
<P/>
Input-output TCP streams are intended to support all operations, implemented
for streams in &GAP;. It is assumed that all existing code using streams
should work with this kind of streams as well (please let us know, if you
will notice that this is not the case!). We installed methods for
input-output TCP streams to support the following operations:
<Ref BookName="ref" Oper="ViewObj"/>,
<Ref BookName="ref" Oper="PrintObj"/>,
<Ref BookName="ref" Oper="ReadByte"/>,
<Ref BookName="ref" Oper="ReadLine"/>,
<Ref BookName="ref" Oper="ReadAll"/>,
<Ref BookName="ref" Oper="WriteByte"/>,
<Ref BookName="ref" Oper="WriteLine"/>,
<Ref BookName="ref" Oper="WriteAll"/>,
<Ref BookName="ref" Oper="IsEndOfStream"/>,
<Ref BookName="ref" Oper="CloseStream"/>,
<Ref BookName="ref" Oper="FileDescriptorOfStream"/>,
<Ref BookName="ref" Oper="UNIXSelect"/>.
<P/>
<Section Label="StreamsExample">
<Heading>Example of client-server communication via input-output TCP streams</Heading>
The following example demonstrates the low-level interaction between client
and server using input-output TCP stream, and shows how such streams are
created in the function <Ref Func="RunSCSCPserver"/>. It uses some
functions from the &IO; package (see the &IO; manual for their
description). We will show step by step what is happens on server and
client (of course, if you will try this example, the numbers denoting
descriptors may be different).
<P/>
First, we will start two &GAP; sessions, one for the server, another one
for the client. Now we enter the following commands on the server's side:
After the last command you will not see the &GAP; prompt because the
server starts to wait for an incoming connection.
Now we go to the client's side and create an input-output TCP stream to
the server. Here it can be created in one step:
<Log>
<![CDATA[
gap> clientstream:=InputOutputTCPStream( "localhost", 26133 );
Creating a socket...
Connecting to a remote socket via TCP/IP...
]]>
</Log>
Now we are trying to connect to the server, and as soon as the connection
will be established, the stream will be created at the client side, and
we will see the output and the new &GAP; prompt:
In this way one can organise remote communication between two copies of
&GAP; in various ways. In subsequent chapters we explain how it is
implemented using &SCSCP; to ensure compatibility not only with &GAP;
but with any other &SCSCP;-compliant system.
</Section>
</Chapter>
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.