CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
<Chapter Label="SCSCPmessages">
2
<Heading>Message exchange by &SCSCP;</Heading>
3
4
To ensure the message exchange as required by &SCSCP; specification, the
5
&SCSCP; package extends the global record <C>OMsymRecord</C> from the
6
&OpenMath; package with new entries to support &scscp1; and &scscp2;
7
content dictionaries (<Cite Key="scscp1cd"/>, <Cite Key="scscp2cd"/>),
8
and also service-dependent transient private content dictionaries
9
(see Chapter <Ref Label="Server"/> for details about transient content
10
dictionaries). It also overwrites some &OpenMath; functions by their
11
extended (but backwards compatible) versions, and adds some new
12
&OpenMath;-related functions to send and receive &SCSCP; messages,
13
documented below.
14
<P/>
15
16
Note that functions documented in this chapter belong to the middle-level
17
interface, and the user may find it more convenient to use functions
18
developed on top of them and explained in next chapters.
19
20
<Section Label="SCSCPclient">
21
<Heading>Communication with the &SCSCP; server</Heading>
22
23
<#Include Label="StartSCSCPsession">
24
<#Include Label="OMPutProcedureCall">
25
<#Include Label="SCSCPwait">
26
<#Include Label="OMGetObjectWithAttributes">
27
28
</Section>
29
30
<Section Label="SCSCPserver">
31
<Heading>Communication with the &SCSCP; client</Heading>
32
33
<#Include Label="OMPutProcedureCompleted">
34
<#Include Label="OMPutProcedureTerminated">
35
36
</Section>
37
38
39
<Section Label="SCSCPsession">
40
<Heading>Example: &SCSCP; session</Heading>
41
42
In the following example we start an &SCSCP; session and perform ten
43
procedure calls in a loop before closing that session. Note that we
44
demonstrate the usage of the session ID <C>sid</C> and the function
45
<C>RandomString</C> from the &OpenMath; package to produce some unique
46
call identifier.
47
The call ID is a mandatory attribute for any procedure call, however,
48
it is not nesessarily random; for example, it may be just a string
49
with the number of the procedure call.
50
<Example>
51
<![CDATA[
52
gap> stream:=InputOutputTCPStream( "localhost", 26133 );
53
< input/output TCP stream to localhost:26133 >
54
gap> sid := StartSCSCPsession( stream );
55
"localhost:26133:5541"
56
gap> res:=[];
57
[ ]
58
gap> for i in [1..10] do
59
> OMPutProcedureCall( stream, "WS_Factorial",
60
> rec( object := [ i ],
61
> attributes := [ [ "call_id",
62
> Concatenation( sid, ":", RandomString(8) ) ] ] ) );
63
> SCSCPwait( stream );
64
> res[i]:=OMGetObjectWithAttributes( stream ).object;
65
> od;
66
gap> CloseStream(stream);
67
gap> res;
68
[ 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800 ]
69
]]>
70
</Example>
71
Also note the usage of <Ref Func="SCSCPwait"/> to wait
72
until the result of the computation will be available from
73
<C>stream</C>.
74
<P/>
75
76
In this example we assumed that there is an &SCSCP; server running
77
at <C>localhost</C>, port 26133. In the next chapter we will explain
78
how to configure and run a &GAP; &SCSCP; server and how to interrogate
79
it from a &GAP; client to learn about its functionality. After that,
80
we will proceed with the &SCSCP; client functionality for the end-user.
81
82
</Section>
83
84
</Chapter>
85