Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 418346<Chapter Label="SCSCPmessages">1<Heading>Message exchange by &SCSCP;</Heading>23To ensure the message exchange as required by &SCSCP; specification, the4&SCSCP; package extends the global record <C>OMsymRecord</C> from the5&OpenMath; package with new entries to support &scscp1; and &scscp2;6content dictionaries (<Cite Key="scscp1cd"/>, <Cite Key="scscp2cd"/>),7and also service-dependent transient private content dictionaries8(see Chapter <Ref Label="Server"/> for details about transient content9dictionaries). It also overwrites some &OpenMath; functions by their10extended (but backwards compatible) versions, and adds some new11&OpenMath;-related functions to send and receive &SCSCP; messages,12documented below.13<P/>1415Note that functions documented in this chapter belong to the middle-level16interface, and the user may find it more convenient to use functions17developed on top of them and explained in next chapters.1819<Section Label="SCSCPclient">20<Heading>Communication with the &SCSCP; server</Heading>2122<#Include Label="StartSCSCPsession">23<#Include Label="OMPutProcedureCall">24<#Include Label="SCSCPwait">25<#Include Label="OMGetObjectWithAttributes">2627</Section>2829<Section Label="SCSCPserver">30<Heading>Communication with the &SCSCP; client</Heading>3132<#Include Label="OMPutProcedureCompleted">33<#Include Label="OMPutProcedureTerminated">3435</Section>363738<Section Label="SCSCPsession">39<Heading>Example: &SCSCP; session</Heading>4041In the following example we start an &SCSCP; session and perform ten42procedure calls in a loop before closing that session. Note that we43demonstrate the usage of the session ID <C>sid</C> and the function44<C>RandomString</C> from the &OpenMath; package to produce some unique45call identifier.46The call ID is a mandatory attribute for any procedure call, however,47it is not nesessarily random; for example, it may be just a string48with the number of the procedure call.49<Example>50<![CDATA[51gap> stream:=InputOutputTCPStream( "localhost", 26133 );52< input/output TCP stream to localhost:26133 >53gap> sid := StartSCSCPsession( stream );54"localhost:26133:5541"55gap> res:=[];56[ ]57gap> for i in [1..10] do58> OMPutProcedureCall( stream, "WS_Factorial",59> rec( object := [ i ],60> attributes := [ [ "call_id",61> Concatenation( sid, ":", RandomString(8) ) ] ] ) );62> SCSCPwait( stream );63> res[i]:=OMGetObjectWithAttributes( stream ).object;64> od;65gap> CloseStream(stream);66gap> res;67[ 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800 ]68]]>69</Example>70Also note the usage of <Ref Func="SCSCPwait"/> to wait71until the result of the computation will be available from72<C>stream</C>.73<P/>7475In this example we assumed that there is an &SCSCP; server running76at <C>localhost</C>, port 26133. In the next chapter we will explain77how to configure and run a &GAP; &SCSCP; server and how to interrogate78it from a &GAP; client to learn about its functionality. After that,79we will proceed with the &SCSCP; client functionality for the end-user.8081</Section>8283</Chapter>8485