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: 4183461[1X6 [33X[0;0YClient's functionality[133X[101X23[33X[0;0YSending and getting requests to the [5XSCSCP[105X server(s), the client operates4with processes. Process is an abstraction which in other words may be also5called a remote task. It encapsulates an input/output TCP stream (see6[2XIsInputOutputTCPStream[102X ([14X3.1-1[114X)) from the client to the server and the7process ID of the CAS running as a server (deduced from the connection8initiation message; may be unassigned, if the server CAS did not communicate9it).[133X1011[33X[0;0YThere are two ways to create processes. One of them is to specify the12hostname and port where the [5XSCSCP[105X server is running; in this case a new13input/output TCP stream will be created. Another way is first to establish14the connection with the [5XSCSCP[105X server using [2XNewSCSCPconnection[102X ([14X6.1-2[114X) and15then keep it alive across multiple remote procedure calls, thus saving time16on the DNS lookup and connection initiation. This may give a good speedup in17computations with an intensive message exchange. Note that as long as such18connection is open, other [5XSCSCP[105X clients will not be able to get through, so19if several clients are interchanging with the [5XSCSCP[105X server at the same time,20they should not block each other with long-lasting connections.[133X212223[1X6.1 [33X[0;0Y[5XSCSCP[105X[101X[1X connections[133X[101X2425[1X6.1-1 IsSCSCPconnection[101X2627[29X[2XIsSCSCPconnection[102X[32X filter2829[33X[0;0YThis is the category of [5XSCSCP[105X connections. Objects in this category are30created using the function [2XNewSCSCPconnection[102X ([14X6.1-2[114X).[133X3132[1X6.1-2 NewSCSCPconnection[101X3334[29X[2XNewSCSCPconnection[102X( [3Xhostname[103X, [3Xport[103X ) [32X function3536[33X[0;0YFor a string [3Xhostname[103X and an integer [3Xport[103X, creates an object in the category37[2XIsSCSCPconnection[102X ([14X6.1-1[114X). This object will encapsulate two objects:38[10Xtcpstream[110X, which is the input/output TCP stream to [10X[3Xhostname[103X[10X:[3Xport[103X[10X[110X, and39[10Xsession_id[110X, which is the result of calling [2XStartSCSCPsession[102X ([14X4.1-1[114X) on40[10Xtcpstream[110X. The connection will be kept alive across multiple remote41procedure calls until it will be closed with [2XCloseSCSCPconnection[102X ([14X6.1-3[114X).[133X4243[4X[32X Example [32X[104X44[4X[28X[128X[104X45[4X[25Xgap>[125X [27XSetInfoLevel( InfoSCSCP, 2 );[127X[104X46[4X[25Xgap>[125X [27Xs:=NewSCSCPconnection("localhost",26133);[127X[104X47[4X[28X#I Creating a socket ...[128X[104X48[4X[28X#I Connecting to a remote socket via TCP/IP ...[128X[104X49[4X[28X#I Got connection initiation message[128X[104X50[4X[28X#I <?scscp service_name="GAP" service_version="4.dev" service_id="localhost:2\[128X[104X51[4X[28X6133:52918" scscp_versions="1.0 1.1 1.2 1.3" ?>[128X[104X52[4X[28X#I Requesting version 1.3 from the server ...[128X[104X53[4X[28X#I Server confirmed version 1.3 to the client ...[128X[104X54[4X[28X< connection to localhost:26133 session_id=localhost:26133:52918 >[128X[104X55[4X[25Xgap>[125X [27XCloseSCSCPconnection(s);[127X[104X56[4X[28X[128X[104X57[4X[32X[104X5859[1X6.1-3 CloseSCSCPconnection[101X6061[29X[2XCloseSCSCPconnection[102X( [3Xs[103X ) [32X function62[6XReturns:[106X [33X[0;10Ynothing[133X6364[33X[0;0YCloses [5XSCSCP[105X connection [3Xs[103X, which must be an object in the category65[2XIsSCSCPconnection[102X ([14X6.1-1[114X). Internally, it just calls [2XCloseStream[102X ([14XReference:66CloseStream[114X) on the underlying input/output TCP stream of [3Xs[103X.[133X6768[4X[32X Example [32X[104X69[4X[28X[128X[104X70[4X[25Xgap>[125X [27XSetInfoLevel( InfoSCSCP, 0 );[127X[104X71[4X[25Xgap>[125X [27Xs:=NewSCSCPconnection("localhost",26133);[127X[104X72[4X[28X< connection to localhost:26133 session_id=localhost:26133:52918 >[128X[104X73[4X[25Xgap>[125X [27XCloseSCSCPconnection(s);[127X[104X74[4X[28X[128X[104X75[4X[32X[104X767778[1X6.2 [33X[0;0YProcesses[133X[101X7980[1X6.2-1 IsProcess[101X8182[29X[2XIsProcess[102X[32X filter8384[33X[0;0YThis is the category of processes. Processes in this category are created85using the function [2XNewProcess[102X ([14X6.2-2[114X).[133X8687[1X6.2-2 NewProcess[101X8889[29X[2XNewProcess[102X( [3Xcommand[103X, [3Xlistargs[103X, [3Xserver[103X, [3Xport[103X ) [32X function90[29X[2XNewProcess[102X( [3Xcommand[103X, [3Xlistargs[103X, [3Xconnection[103X ) [32X function91[6XReturns:[106X [33X[0;10Yobject in the category [10XIsProcess[110X[133X9293[33X[0;0YIn the first form, [3Xcommand[103X and [10Xserver[110X are strings, [3Xlistargs[103X is a list of [5XGAP[105X94objects and [10Xport[110X is an integer.[133X9596[33X[0;0YIn the second form, an [5XSCSCP[105X connection in the category [2XNewSCSCPconnection[102X97([14X6.1-2[114X) is used instead of [10Xserver[110X and [10Xport[110X.[133X9899[33X[0;0YCalls the [5XSCSCP[105X procedure with the name [3Xcommand[103X and the list of arguments100[3Xlistargs[103X at the server and port given by [3Xserver[103X and [3Xport[103X or encapsulated in101the [3Xconnection[103X. Returns an object in the category [10XIsProcess[110X for the102subsequent waiting the result from its underlying stream.[133X103104[33X[0;0YIt accepts the following options:[133X105106[30X [33X[0;6Y[10Xoutput:="object"[110X is used to specify that the server must return the107actual object evaluated as a result of the procedure call. This is the108default action requested by the client if the [10Xoutput[110X option is109omitted.[133X110111[30X [33X[0;6Y[10Xoutput:="cookie"[110X is used to specify that the result of the procedure112call should be stored on the server, and the server should return a113remote object (see [14X6.5[114X ) pointing to that result (that is, a cookie);[133X114115[30X [33X[0;6Y[10Xoutput:="nothing"[110X is used to specify that the server is supposed to116reply with a [10Xprocedure_completed[110X message carrying no object just to117signal that the call was completed successfully (for the118compatibility, this will be evaluated to a [10X"procedure completed"[110X119string on the client's side);[133X120121[30X [33X[0;6Y[10Xcd:="cdname"[110X is used to specify that the [5XOpenMath[105X symbol corresponding122to the first argument [3Xcommand[103X should be looked up in the particular123content dictionary [10Xcdname[110X. Otherwise, it will be looked for in the124default content dictionary ([10Xscscp_transient_1[110X for the [5XGAP[105X [5XSCSCP[105X125server);[133X126127[30X [33X[0;6Y[10Xdebuglevel:=N[110X is used to obtain additional information attributes128together with the result. The [5XGAP[105X [5XSCSCP[105X server does the following: if129[10XN=1[110X, it will report about the CPU time in milliseconds required to130compute the result; if [10XN=2[110X it will additionally report about the131amount of memory used by [5XGAP[105X in bytes will be returned (using the132output of [2XMemoryUsageByGAPinKbytes[102X ([14X9.3-4[114X) converted to bytes); if [10XN=3[110X133it will additionally report the amount of memory in bytes used by the134resulting object and its subobjects (using the output of [2XMemoryUsage[102X135([14XReference: MemoryUsage[114X)).[133X136137[33X[0;0YSee [2XCompleteProcess[102X ([14X6.2-3[114X) and [2XEvaluateBySCSCP[102X ([14X6.3-1[114X) for examples.[133X138139[1X6.2-3 CompleteProcess[101X140141[29X[2XCompleteProcess[102X( [3Xprocess[103X ) [32X function142[6XReturns:[106X [33X[0;10Yrecord with components [10Xobject[110X and [10Xattributes[110X[133X143144[33X[0;0YThe function waits, if necessary, until the underlying stream of the process145will contain some data, then reads the appropriate [5XOpenMath[105X object from this146stream and closes it.[133X147148[33X[0;0YIt has the option [10Xoutput[110X which may have two values:[133X149150[30X [33X[0;6Y[10Xoutput:="cookie"[110X has the same meaning as for the [2XNewProcess[102X ([14X6.2-2[114X)[133X151152[30X [33X[0;6Y[10Xoutput:="tree"[110X is used to specify that the result obtained from the153server should be returned as an XML parsed tree without its154evaluation.[133X155156[33X[0;0YIn the following example we demonstrate combination of the two previous157functions to send request and get result, calling the procedure158[10XWS_Factorial[110X, installed in the previous chapter:[133X159160[4X[32X Example [32X[104X161[4X[28X[128X[104X162[4X[25Xgap>[125X [27Xs := NewProcess( "WS_Factorial", [10], "localhost", 26133 ); [127X[104X163[4X[28X< process at localhost:26133 pid=52918 >[128X[104X164[4X[25Xgap>[125X [27Xx := CompleteProcess(s);[127X[104X165[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:52918:TPNiMjCT" ] ],[128X[104X166[4X[28X object := 3628800 )[128X[104X167[4X[28X[128X[104X168[4X[32X[104X169170[33X[0;0YSee more examples in the description of the function [2XEvaluateBySCSCP[102X171([14X6.3-1[114X), which combines the two previous functions by sending request and172getting result in one call.[133X173174[1X6.2-4 TerminateProcess[101X175176[29X[2XTerminateProcess[102X( [3Xprocess[103X ) [32X function177178[33X[0;0YThe function is supposed to send an [21Xout-of-band[121X interrupt signal to the179server. Current implementation works only when the server is running as180[21Xlocalhost[121X by sending a [10XSIGINT[110X to the server using its PID contained in the181[3Xprocess[103X. It will do nothing if the server is running remotely, as the [5XSCSCP[105X182specification allows the server to ignore interrupt messages. Remote183interrupts will be introduced in one of the next versions of the package.[133X184185186[1X6.3 [33X[0;0YAll-in-one tool: sending request and getting result[133X[101X187188[1X6.3-1 EvaluateBySCSCP[101X189190[29X[2XEvaluateBySCSCP[102X( [3Xcommand[103X, [3Xlistargs[103X, [3Xserver[103X, [3Xport[103X ) [32X function191[29X[2XEvaluateBySCSCP[102X( [3Xcommand[103X, [3Xlistargs[103X, [3Xconnection[103X ) [32X function192[6XReturns:[106X [33X[0;10Yrecord with components [10Xobject[110X and [10Xattributes[110X[133X193194[33X[0;0YIn the first form, [3Xcommand[103X and [10Xserver[110X are strings, [3Xlistargs[103X is a list of [5XGAP[105X195objects and [10Xport[110X is an integer.[133X196197[33X[0;0YIn the second form, an [5XSCSCP[105X connection in the category [2XNewSCSCPconnection[102X198([14X6.1-2[114X) is used instead of [10Xserver[110X and [10Xport[110X.[133X199200[33X[0;0YCalls the SCSCP procedure with the name [3Xcommand[103X and the list of arguments201[3Xlistargs[103X at the server and port given by [10Xserver[110X and [10Xport[110X or encapsulated in202the [3Xconnection[103X.[133X203204[33X[0;0YSince [2XEvaluateBySCSCP[102X combines [2XNewProcess[102X ([14X6.2-2[114X) and [2XCompleteProcess[102X205([14X6.2-3[114X), it accepts all options which may be used by that functions (206[10Xoutput[110X, [10Xcd[110X and [10Xdebuglevel[110X ) with the same meanings.[133X207208[4X[32X Example [32X[104X209[4X[28X[128X[104X210[4X[25Xgap>[125X [27XEvaluateBySCSCP( "WS_Factorial",[10],"localhost",26133);[127X[104X211[4X[28X#I Creating a socket ...[128X[104X212[4X[28X#I Connecting to a remote socket via TCP/IP ...[128X[104X213[4X[28X#I Got connection initiation message[128X[104X214[4X[28X#I Requesting version 1.3 from the server ...[128X[104X215[4X[28X#I Server confirmed version 1.3 to the client ...[128X[104X216[4X[28X#I Request sent ...[128X[104X217[4X[28X#I Waiting for reply ...[128X[104X218[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:2442:6hMEN40d" ] ], [128X[104X219[4X[28X object := 3628800 )[128X[104X220[4X[25Xgap>[125X [27XSetInfoLevel(InfoSCSCP,0);[127X[104X221[4X[25Xgap>[125X [27XEvaluateBySCSCP( "WS_Factorial",[10],"localhost",26133 : output:="cookie" ); [127X[104X222[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:2442:jNQG6rml" ] ], [128X[104X223[4X[28X object := < remote object scscp://localhost:26133/TEMPVarSCSCP5KZIeiKD > )[128X[104X224[4X[25Xgap>[125X [27XEvaluateBySCSCP( "WS_Factorial",[10],"localhost",26133 : output:="nothing" );[127X[104X225[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:2442:9QHQrCjv" ] ], [128X[104X226[4X[28X object := "procedure completed" )[128X[104X227[4X[28X[128X[104X228[4X[32X[104X229230[33X[0;0YNow we demonstrate the procedure [10XGroupIdentificationService[110X, also given in231the previous chapter:[133X232233[4X[32X Example [32X[104X234[4X[28X[128X[104X235[4X[25Xgap>[125X [27XG:=SymmetricGroup(4);[127X[104X236[4X[28XSym( [ 1 .. 4 ] )[128X[104X237[4X[25Xgap>[125X [27Xgens:=GeneratorsOfGroup(G);[127X[104X238[4X[28X[ (1,2,3,4), (1,2) ][128X[104X239[4X[25Xgap>[125X [27XEvaluateBySCSCP( "GroupIdentificationService", [ gens ],[127X[104X240[4X[25X>[125X [27X "localhost", 26133 : debuglevel:=3 ); [127X[104X241[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:2442:xOilXtnw" ], [128X[104X242[4X[28X [ "info_runtime", 4 ], [ "info_memory", 2596114432 ], [128X[104X243[4X[28X [ "info_message", "Memory usage for the result is 48 bytes" ] ], [128X[104X244[4X[28X object := [ 24, 12 ] )[128X[104X245[4X[28X[128X[104X246[4X[32X[104X247248[33X[0;0YService provider may suggest to the client to use a counterpart function[133X249250[4X[32X Example [32X[104X251[4X[28X[128X[104X252[4X[25Xgap>[125X [27XIdGroupWS := function( G )[127X[104X253[4X[25X>[125X [27X local H, result;[127X[104X254[4X[25X>[125X [27X if not IsPermGroup(G) then[127X[104X255[4X[25X>[125X [27X H:= Image( IsomorphismPermGroup( G ) );[127X[104X256[4X[25X>[125X [27X else[127X[104X257[4X[25X>[125X [27X H := G;[127X[104X258[4X[25X>[125X [27X fi; [127X[104X259[4X[25X>[125X [27X result := EvaluateBySCSCP ( "GroupIdentificationService", [127X[104X260[4X[25X>[125X [27X [ GeneratorsOfGroup(H) ], "localhost", 26133 );[127X[104X261[4X[25X>[125X [27X return result.object;[127X[104X262[4X[25X>[125X [27Xend;;[127X[104X263[4X[28X[128X[104X264[4X[32X[104X265266[33X[0;0Ywhich works exactly like [2XIdGroup[102X ([14XReference: IdGroup[114X):[133X267268[4X[32X Example [32X[104X269[4X[28X[128X[104X270[4X[25Xgap>[125X [27XG:=DihedralGroup(64);[127X[104X271[4X[28X<pc group of size 64 with 6 generators>[128X[104X272[4X[25Xgap>[125X [27XIdGroupWS(G);[127X[104X273[4X[28X[ 64, 52 ][128X[104X274[4X[28X[128X[104X275[4X[32X[104X276277278[1X6.4 [33X[0;0YSwitching between Binary and XML [5XOpenMath[105X[101X[1X Encodings[133X[101X279280[1X6.4-1 SwitchSCSCPmodeToBinary[101X281282[29X[2XSwitchSCSCPmodeToBinary[102X( ) [32X function283[29X[2XSwitchSCSCPmodeToXML[102X( ) [32X function284[6XReturns:[106X [33X[0;10Ynothing[133X285286[33X[0;0YThe [5XOpenMath[105X package supports both binary and XML encodings for [5XOpenMath[105X. To287switch between them, use [2XSwitchSCSCPmodeToBinary[102X and [2XSwitchSCSCPmodeToXML[102X.288When the package is loaded, the mode is initially set to XML. On the289clients's side, you can change the mode back and forth as many times as you290wish during the same [5XSCSCP[105X session. The server will autodetect the mode and291will response in the same format, so one does not need to set the mode on292the server's side.[133X293294[33X[0;0YFor example, let us create a vector over [22XGF(3)[122X:[133X295296[4X[32X Example [32X[104X297[4X[28X[128X[104X298[4X[25Xgap>[125X [27Xx := [ Z(3)^0, Z(3), 0*Z(3) ];[127X[104X299[4X[28X[ Z(3)^0, Z(3), 0*Z(3) ][128X[104X300[4X[28X[128X[104X301[4X[32X[104X302303[33X[0;0YThe XML [5XOpenMath[105X encoding of such objects is quite bulky:[133X304305[4X[32X Example [32X[104X306[4X[28X[128X[104X307[4X[25Xgap>[125X [27XOMString( x );[127X[104X308[4X[28X"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\" version=\"2.0\"> <OMA> <OMS\[128X[104X309[4X[28X cd=\"list1\" name=\"list\"/> <OMA> <OMS cd=\"arith1\" name=\"power\"/> <OMA> \[128X[104X310[4X[28X<OMS cd=\"finfield1\" name=\"primitive_element\"/> <OMI>3</OMI> </OMA> <OMI>0<\[128X[104X311[4X[28X/OMI> </OMA> <OMA> <OMS cd=\"arith1\" name=\"power\"/> <OMA> <OMS cd=\"finfiel\[128X[104X312[4X[28Xd1\" name=\"primitive_element\"/> <OMI>3</OMI> </OMA> <OMI>1</OMI> </OMA> <OMA\[128X[104X313[4X[25X>[125X [27X<OMS cd=\"arith1\" name=\"times\"/> <OMA> <OMS cd=\"finfield1\" name=\"primi\[127X[104X314[4X[28Xtive_element\"/> <OMI>3</OMI> </OMA> <OMI>0</OMI> </OMA> </OMA> </OMOBJ>"[128X[104X315[4X[25Xgap>[125X [27XLength( OMString(x) );[127X[104X316[4X[28X507[128X[104X317[4X[28X[128X[104X318[4X[32X[104X319320[33X[0;0YWe call the [5XSCSCP[105X procedure [10XIdentity[110X just to test how this object may be321sent back and forth. The total length of the procedure call message is 969322symbols:[133X323324[4X[32X Example [32X[104X325[4X[28X[128X[104X326[4X[25Xgap>[125X [27XSetInfoLevel(InfoSCSCP,3);[127X[104X327[4X[25Xgap>[125X [27XEvaluateBySCSCP("Identity",[x],"localhost",26133);[127X[104X328[4X[28X#I Creating a socket ...[128X[104X329[4X[28X#I Connecting to a remote socket via TCP/IP ...[128X[104X330[4X[28X#I Got connection initiation message[128X[104X331[4X[28X#I <?scscp service_name="GAP" service_version="4.dev" service_id="localhost:2\[128X[104X332[4X[28X6133:42448" scscp_versions="1.0 1.1 1.2 1.3" ?>[128X[104X333[4X[28X#I Requesting version 1.3 from the server ...[128X[104X334[4X[28X#I Server confirmed version 1.3 to the client ...[128X[104X335[4X[28X#I Composing procedure_call message: [128X[104X336[4X[28X<?scscp start ?>[128X[104X337[4X[28X<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">[128X[104X338[4X[28X <OMATTR>[128X[104X339[4X[28X <OMATP>[128X[104X340[4X[28X <OMS cd="scscp1" name="call_id"/>[128X[104X341[4X[28X <OMSTR>localhost:26133:42448:IOs9ZkBU</OMSTR>[128X[104X342[4X[28X <OMS cd="scscp1" name="option_return_object"/>[128X[104X343[4X[28X <OMSTR></OMSTR>[128X[104X344[4X[28X </OMATP>[128X[104X345[4X[28X <OMA>[128X[104X346[4X[28X <OMS cd="scscp1" name="procedure_call"/>[128X[104X347[4X[28X <OMA>[128X[104X348[4X[28X <OMS cd="scscp_transient_1" name="Identity"/>[128X[104X349[4X[28X <OMA>[128X[104X350[4X[28X <OMS cd="list1" name="list"/>[128X[104X351[4X[28X <OMA>[128X[104X352[4X[28X <OMS cd="arith1" name="power"/>[128X[104X353[4X[28X <OMA>[128X[104X354[4X[28X <OMS cd="finfield1" name="primitive_element"/>[128X[104X355[4X[28X <OMI>3</OMI>[128X[104X356[4X[28X </OMA>[128X[104X357[4X[28X <OMI>0</OMI>[128X[104X358[4X[28X </OMA>[128X[104X359[4X[28X <OMA>[128X[104X360[4X[28X <OMS cd="arith1" name="power"/>[128X[104X361[4X[28X <OMA>[128X[104X362[4X[28X <OMS cd="finfield1" name="primitive_element"/>[128X[104X363[4X[28X <OMI>3</OMI>[128X[104X364[4X[28X </OMA>[128X[104X365[4X[28X <OMI>1</OMI>[128X[104X366[4X[28X </OMA>[128X[104X367[4X[28X <OMA>[128X[104X368[4X[28X <OMS cd="arith1" name="times"/>[128X[104X369[4X[28X <OMA>[128X[104X370[4X[28X <OMS cd="finfield1" name="primitive_element"/>[128X[104X371[4X[28X <OMI>3</OMI>[128X[104X372[4X[28X </OMA>[128X[104X373[4X[28X <OMI>0</OMI>[128X[104X374[4X[28X </OMA>[128X[104X375[4X[28X </OMA>[128X[104X376[4X[28X </OMA>[128X[104X377[4X[28X </OMA>[128X[104X378[4X[28X </OMATTR>[128X[104X379[4X[28X</OMOBJ>[128X[104X380[4X[28X<?scscp end ?>[128X[104X381[4X[28X#I Total length 969 characters [128X[104X382[4X[28X...[128X[104X383[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:42448:IOs9ZkBU" ] ], [128X[104X384[4X[28X object := [ Z(3)^0, Z(3), 0*Z(3) ] )[128X[104X385[4X[28X [128X[104X386[4X[32X[104X387388[33X[0;0YNow we switch to binary mode:[133X389390[4X[32X Example [32X[104X391[4X[28X[128X[104X392[4X[25Xgap>[125X [27XSwitchSCSCPmodeToBinary();[127X[104X393[4X[25Xgap>[125X [27XEvaluateBySCSCP("Identity",[x],"localhost",26133);[127X[104X394[4X[28X#I Creating a socket ...[128X[104X395[4X[28X#I Connecting to a remote socket via TCP/IP ...[128X[104X396[4X[28X#I Got connection initiation message[128X[104X397[4X[28X#I <?scscp service_name="GAP" service_version="4.dev" service_id="localhost:2\[128X[104X398[4X[28X6133:42448" scscp_versions="1.0 1.1 1.2 1.3" ?>[128X[104X399[4X[28X#I Requesting version 1.3 from the server ...[128X[104X400[4X[28X#I Server confirmed version 1.3 to the client ...[128X[104X401[4X[28X#I Composing procedure_call message: [128X[104X402[4X[28X3C3F7363736370207374617274203F3E0A18121408060773637363703163616C6C5F6964061E6C\[128X[104X403[4X[28X6F63616C686F73743A32363133333A34323434383A3256675A5562755A0806147363736370316F\[128X[104X404[4X[28X7074696F6E5F72657475726E5F6F626A6563740600151008060E73637363703170726F63656475\[128X[104X405[4X[28X72655F63616C6C1008110873637363705F7472616E7369656E745F314964656E74697479100805\[128X[104X406[4X[28X046C697374316C69737410080605617269746831706F7765721008091166696E6669656C643170\[128X[104X407[4X[28X72696D69746976655F656C656D656E7401031101001110080605617269746831706F7765721008\[128X[104X408[4X[28X091166696E6669656C64317072696D69746976655F656C656D656E740103110101111008060561\[128X[104X409[4X[28X726974683174696D65731008091166696E6669656C64317072696D69746976655F656C656D656E\[128X[104X410[4X[28X7401031101001111111113193C3F736373637020656E64203F3E0A[128X[104X411[4X[28X#I Total length 339 bytes [128X[104X412[4X[28X#I Request sent ...[128X[104X413[4X[28X#I Waiting for reply ...[128X[104X414[4X[28X#I <?scscp start ?>[128X[104X415[4X[28X#I Got back: object [ Z(3)^0, Z(3), 0*Z(3) ] with attributes [128X[104X416[4X[28X[ [ "call_id", "localhost:26133:42448:2VgZUbuZ" ] ][128X[104X417[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:42448:2VgZUbuZ" ] ], [128X[104X418[4X[28X object := [ Z(3)^0, Z(3), 0*Z(3) ] )[128X[104X419[4X[25Xgap>[125X [27XSetInfoLevel(InfoSCSCP,3);[127X[104X420[4X[28X[128X[104X421[4X[32X[104X422423[33X[0;0YAs we can see, the size of the message is almost three times shorter, and424this is not the limit. Switching to binary [5XOpenMath[105X encoding in combination425with pickling and unpickling from [5XIO[105X package (see in the last Chapter) and426special methods for pickling compressed vectors implemented in the [5XCvec[105X427available in [5XGAP[105X 4.5 allow to dramatically reduce the overhead for vectors428and matrices over finite fields, making a roundtrip up to a thousand times429faster.[133X430431432[1X6.5 [33X[0;0YRemote objects[133X[101X433434[33X[0;0YThe [5XSCSCP[105X package introduces new kind of objects - [13Xremote objects[113X. They435provide an opportunity to manipulate with objects on remote services without436their actual transmitting over the network. Remote objects store the437information that allows to access the original object: the server name and438the port number through which the object can be accessed, and the variable439name under which it is stored in the remote system. Two remote objects are440equal if and only if all these three parameters coincide.[133X441442[33X[0;0YThere are two types of remote object which differ by their lifetime:[133X443444[30X [33X[0;6Ytemporary remote objects which exist only within a single session;[133X445446[30X [33X[0;6Ypersistent remote objects which stay alive across multiple sessions.[133X447448[33X[0;0YFirst we show the example of the temporary remote object in a session. The449procedure [10XPointImages[110X returns the set of images of a point [22Xi[122X under the450generators of the group [22XG[122X. First we create the symmetric group [22XS_3[122X on the451client and store it remotely on the server (call 1), then we compute set of452images for [22Xi=1,2[122X (calls 2,3) and finally demonstrate that we may retrieve453the group from the server (call 4):[133X454455[4X[32X Example [32X[104X456[4X[28X[128X[104X457[4X[25Xgap>[125X [27Xstream:=InputOutputTCPStream( "localhost", 26133 );[127X[104X458[4X[28X< input/output TCP stream to localhost:26133 >[128X[104X459[4X[25Xgap>[125X [27XStartSCSCPsession(stream);[127X[104X460[4X[28X"localhost:26133:6184"[128X[104X461[4X[25Xgap>[125X [27XOMPutProcedureCall( stream, "store_session", [127X[104X462[4X[25X>[125X [27X rec( object := [ SymmetricGroup(3) ], [127X[104X463[4X[25X>[125X [27X attributes := [ [ "call_id", "1" ], [127X[104X464[4X[25X>[125X [27X ["option_return_cookie"] ] ) );[127X[104X465[4X[28Xtrue[128X[104X466[4X[25Xgap>[125X [27XSCSCPwait( stream );[127X[104X467[4X[25Xgap>[125X [27XG:=OMGetObjectWithAttributes( stream ).object;[127X[104X468[4X[28X< remote object scscp://localhost:26133/TEMPVarSCSCPo3Bc8J75 >[128X[104X469[4X[25Xgap>[125X [27XOMPutProcedureCall( stream, "PointImages", [127X[104X470[4X[25X>[125X [27X rec( object := [ G, 1 ], [127X[104X471[4X[25X>[125X [27X attributes := [ [ "call_id", "2" ] ] ) );[127X[104X472[4X[28Xtrue[128X[104X473[4X[25Xgap>[125X [27XSCSCPwait( stream );[127X[104X474[4X[25Xgap>[125X [27XOMGetObjectWithAttributes( stream );[127X[104X475[4X[28Xrec( attributes := [ [ "call_id", "2" ] ], object := [ 2 ] )[128X[104X476[4X[25Xgap>[125X [27XOMPutProcedureCall( stream, "PointImages", [127X[104X477[4X[25X>[125X [27X rec( object := [ G, 2 ], [127X[104X478[4X[25X>[125X [27X attributes := [ [ "call_id", "3" ] ] ) );[127X[104X479[4X[28Xtrue[128X[104X480[4X[25Xgap>[125X [27XSCSCPwait( stream );[127X[104X481[4X[25Xgap>[125X [27XOMGetObjectWithAttributes( stream );[127X[104X482[4X[28Xrec( attributes := [ [ "call_id", "3" ] ], object := [ 1, 3 ] )[128X[104X483[4X[25Xgap>[125X [27XOMPutProcedureCall( stream, "retrieve", [127X[104X484[4X[25X>[125X [27X rec( object := [ G ], [127X[104X485[4X[25X>[125X [27X attributes := [ [ "call_id", "4" ] ] ) );[127X[104X486[4X[28Xtrue[128X[104X487[4X[25Xgap>[125X [27XSCSCPwait( stream );[127X[104X488[4X[25Xgap>[125X [27XOMGetObjectWithAttributes( stream );[127X[104X489[4X[28Xrec( attributes := [ [ "call_id", "4" ] ], [128X[104X490[4X[28X object := Group([ (1,2,3), (1,2) ]) )[128X[104X491[4X[25Xgap>[125X [27XCloseStream(stream);[127X[104X492[4X[28X[128X[104X493[4X[32X[104X494495[33X[0;0YAfter the stream is closed, it is no longer possible to retrieve the group [22XG[122X496again or use it as an argument.[133X497498[33X[0;0YThus, the usage of remote objects existing during a session reduces the499network traffic, since we pass only references instead of actual [5XOpenMath[105X500representation of an object. Also, the remote object on the server may501accumulate certain information in its properties and attributes, which may502not be included in it default [5XOpenMath[105X representation.[133X503504[33X[0;0YNow we show remote objects which remain alive after the session is closed.505Such remote objects may be accessed later, for example, by:[133X506507[30X [33X[0;6Ysubsequent procedure calls from the same instance of [5XGAP[105X or another508system;[133X509510[30X [33X[0;6Yother instances of [5XGAP[105X or another systems (if the identifier of an511object is known)[133X512513[30X [33X[0;6Yanother [5XSCSCP[105X servers which obtained a reference to such object as an514argument of a procedure call.[133X515516[1X6.5-1 StoreAsRemoteObjectPersistently[101X517518[29X[2XStoreAsRemoteObjectPersistently[102X( [3Xobj[103X, [3Xserver[103X, [3Xport[103X ) [32X function519[29X[2XStoreAsRemoteObject[102X( [3Xobj[103X, [3Xserver[103X, [3Xport[103X ) [32X function520[6XReturns:[106X [33X[0;10Yremote object[133X521522[33X[0;0YReturns the remote object corresponding to the object created at [3Xserver[103X[10X:[110X[3Xport[103X523from the [5XOpenMath[105X representation of the first argument [3Xobj[103X. The second form524is just a synonym.[133X525526[4X[32X Example [32X[104X527[4X[28X[128X[104X528[4X[25Xgap>[125X [27Xs:=StoreAsRemoteObject( SymmetricGroup(3), "localhost", 26133 );[127X[104X529[4X[28X< remote object scscp://localhost:26133/TEMPVarSCSCPLvIUUtL3 >[128X[104X530[4X[28X[128X[104X531[4X[32X[104X532533[33X[0;0YInternally, the remote object carries all the information which is required534to get access to the original object: its identifier, server and port:[133X535536[4X[32X Example [32X[104X537[4X[28X[128X[104X538[4X[25Xgap>[125X [27Xs![1]; [127X[104X539[4X[28X"TEMPVarSCSCPLvIUUtL3"[128X[104X540[4X[25Xgap>[125X [27Xs![2];[127X[104X541[4X[28X"localhost"[128X[104X542[4X[25Xgap>[125X [27Xs![3];[127X[104X543[4X[28X26133[128X[104X544[4X[28X[128X[104X545[4X[32X[104X546547[33X[0;0YWhen the remote object is printed in the [5XOpenMath[105X format, we use symbols [10X@[110X548and [10X:[110X to combine these parameters in the [5XOpenMath[105X reference:[133X549550[4X[32X Example [32X[104X551[4X[28X[128X[104X552[4X[25Xgap>[125X [27XOMPrint(s);[127X[104X553[4X[28X<OMOBJ>[128X[104X554[4X[28X <OMR href="scscp://localhost:26133/TEMPVarSCSCPLvIUUtL3" />[128X[104X555[4X[28X</OMOBJ>[128X[104X556[4X[28X[128X[104X557[4X[32X[104X558559[33X[0;0YThis allows substitution of remote object as arguments into procedure calls560in the same manner like we do this with usual objects:[133X561562[4X[32X Example [32X[104X563[4X[28X[128X[104X564[4X[25Xgap>[125X [27XEvaluateBySCSCP("WS_IdGroup",[s],"localhost",26133); [127X[104X565[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:52918:Viq6EWBP" ] ],[128X[104X566[4X[28XLine 183 : [128X[104X567[4X[28X object := [ 6, 1 ] )[128X[104X568[4X[28X[128X[104X569[4X[32X[104X570571[1X6.5-2 IsRemoteObject[101X572573[29X[2XIsRemoteObject[102X[32X filter574575[33X[0;0YThis is the category of remote objects.[133X576577[1X6.5-3 RemoteObjectsFamily[101X578579[29X[2XRemoteObjectsFamily[102X[32X family580581[33X[0;0YThis is the family of remote objects.[133X582583[1X6.5-4 RetrieveRemoteObject[101X584585[29X[2XRetrieveRemoteObject[102X( [3Xremoteobject[103X ) [32X function586[6XReturns:[106X [33X[0;10Yobject[133X587588[33X[0;0YThis function retrieves the remote object from the remote service in the589[5XOpenMath[105X format and constructs it locally. Note, however, that for a complex590mathematical object its default [5XOpenMath[105X representation may not contain all591information about it which was accumulated during its lifetime on the [5XSCSCP[105X592server.[133X593594[4X[32X Example [32X[104X595[4X[28X[128X[104X596[4X[25Xgap>[125X [27XRetrieveRemoteObject(s);[127X[104X597[4X[28XGroup([ (1,2,3), (1,2) ])[128X[104X598[4X[28X[128X[104X599[4X[32X[104X600601[1X6.5-5 UnbindRemoteObject[101X602603[29X[2XUnbindRemoteObject[102X( [3Xremoteobject[103X ) [32X function604[6XReturns:[106X [33X[0;10Y[9Xtrue[109X or [9Xfalse[109X[133X605606[33X[0;0YRemoves any value currently bound to the global variable determined by607[3Xremoteobject[103X at the [5XSCSCP[105X server, and returns [9Xtrue[109X or [9Xfalse[109X dependently on608whether this action was successful or not.[133X609610[4X[32X Example [32X[104X611[4X[28X[128X[104X612[4X[25Xgap>[125X [27XUnbindRemoteObject(s);[127X[104X613[4X[28Xtrue[128X[104X614[4X[28X[128X[104X615[4X[32X[104X616617[33X[0;0YFinally, we show an example when first we create a group on the service618running on port 26133, and then identify it on the service running on port61926134:[133X620621[4X[32X Example [32X[104X622[4X[28X[128X[104X623[4X[25Xgap>[125X [27Xs:=StoreAsRemoteObject( SymmetricGroup(3), "localhost", 26133 );[127X[104X624[4X[28X< remote object scscp://localhost:26133/TEMPVarSCSCPNqc8Bkan >[128X[104X625[4X[25Xgap>[125X [27XEvaluateBySCSCP( "WS_IdGroup", [ s ], "localhost", 26134 );[127X[104X626[4X[28Xrec( object := [ 6, 1 ], attributes := [ [ "call_id", "localhost:26134:7414" ] ] )[128X[104X627[4X[28X[128X[104X628[4X[32X[104X629630[33X[0;0YInstead of transmitting the group to the client and then sending it as an631argument to the second service, the latter service directly retrieves the632group from the first service:[133X633634[4X[32X Example [32X[104X635[4X[28X[128X[104X636[4X[25Xgap>[125X [27XEvaluateBySCSCP("WS_IdGroup",[s],"localhost",26133 : output:="cookie" );[127X[104X637[4X[28Xrec( attributes := [ [ "call_id", "localhost:26133:52918:mRU6w471" ] ], [128X[104X638[4X[28X object := < remote object scscp://localhost:26133/TEMPVarSCSCPS9SVe9PZ > )[128X[104X639[4X[28X[128X[104X640[4X[32X[104X641642643644