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
2
9 Service functions
3
4
5
9.1 Pinging SCSCP servers
6
7
9.1-1 PingSCSCPservice
8
9
PingSCSCPservice( hostname, portnumber )  function
10
Returns: true or fail
11
12
This function returns true if the client can establish connection with the
13
SCSCP server at hostname:portnumber. Otherwise, it returns fail.
14
15
 Example 
16

17
gap> PingSCSCPservice("localhost",26133);
18
true
19
gap> PingSCSCPservice("localhost",26140); 
20
Error: rec(
21
 message := "Connection refused",
22
 number := 61 )
23
fail
24

25

26
27
9.1-2 PingStatistic
28
29
PingStatistic( hostname, portnumber, n )  function
30
Returns: nothing
31
32
The function is similar to the UNIX ping. It tries n times to establish
33
connection with the SCSCP server at hostname:portnumber, and then displays
34
statistical information.
35
36
 Example 
37

38
gap> PingStatistic("localhost",26133,1000);
39
1000 packets transmitted, 1000 received, 0% packet loss, time 208ms
40
min/avg/max = [ 0, 26/125, 6 ]
41

42

43
44
45
9.2 Info classes for SCSCP
46
47
9.2-1 InfoSCSCP
48
49
InfoSCSCP info class
50
51
InfoSCSCP is a special Info class for the SCSCP package. The amount of
52
information to be displayed can be specified by the user by setting
53
InfoLevel for this class from 0 to 4, and the default value of InfoLevel for
54
the package is specified in the file scscp/config.g. The higher the level
55
is, the more information will be displayed. To change the InfoLevel to k,
56
use the command SetInfoLevel(InfoSCSCP, k). In the following examples we
57
demonstrate various degrees of output details using Info messages.
58
59
Default Info level:
60
61
 Example 
62

63
gap> SetInfoLevel(InfoSCSCP,2); 
64
gap> EvaluateBySCSCP( "WS_Factorial",[10],"localhost",26133); 
65
#I Creating a socket ...
66
#I Connecting to a remote socket via TCP/IP ...
67
#I Got connection initiation message
68
#I <?scscp service_name="GAP" service_version="4.dev" service_id="localhost:2\
69
6133:286" scscp_versions="1.0 1.1 1.2 1.3" ?>
70
#I Requesting version 1.3 from the server ...
71
#I Server confirmed version 1.3 to the client ...
72
#I Request sent ...
73
#I Waiting for reply ...
74
#I <?scscp start ?>
75
#I <?scscp end ?>
76
#I Got back: object 3628800 with attributes 
77
[ [ "call_id", "localhost:26133:286:JL6KRQeh" ] ]
78
rec( attributes := [ [ "call_id", "localhost:26133:286:JL6KRQeh" ] ], 
79
 object := 3628800 )
80

81

82
83
Minimal Info level:
84
85
 Example 
86

87
gap> SetInfoLevel(InfoSCSCP,0); 
88
gap> EvaluateBySCSCP( "WS_Factorial",[10],"localhost",26133);
89
rec( attributes := [ [ "call_id", "localhost:26133:286:jzjsp6th" ] ], 
90
 object := 3628800 )
91

92

93
94
Verbose Info level:
95
96
 Example 
97

98
gap> SetInfoLevel(InfoSCSCP,3);
99
gap> EvaluateBySCSCP( "WS_Factorial",[10],"localhost",26133);
100
#I Creating a socket ...
101
#I Connecting to a remote socket via TCP/IP ...
102
#I Got connection initiation message
103
#I <?scscp service_name="GAP" service_version="4.dev" service_id="localhost:2\
104
6133:286" scscp_versions="1.0 1.1 1.2 1.3" ?>
105
#I Requesting version 1.3 from the server ...
106
#I Server confirmed version 1.3 to the client ...
107
#I Composing procedure_call message: 
108
<?scscp start ?>
109
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
110
 <OMATTR>
111
 <OMATP>
112
 <OMS cd="scscp1" name="call_id"/>
113
 <OMSTR>localhost:26133:286:Jok6cQAf</OMSTR>
114
 <OMS cd="scscp1" name="option_return_object"/>
115
 <OMSTR></OMSTR>
116
 </OMATP>
117
 <OMA>
118
 <OMS cd="scscp1" name="procedure_call"/>
119
 <OMA>
120
 <OMS cd="scscp_transient_1" name="WS_Factorial"/>
121
 <OMI>10</OMI>
122
 </OMA>
123
 </OMA>
124
 </OMATTR>
125
</OMOBJ>
126
<?scscp end ?>
127
#I Total length 396 characters 
128
#I Request sent ...
129
#I Waiting for reply ...
130
#I <?scscp start ?>
131
#I Received message: 
132
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
133
 <OMATTR>
134
 <OMATP>
135
 <OMS cd="scscp1" name="call_id"/>
136
 <OMSTR>localhost:26133:286:Jok6cQAf</OMSTR>
137
 </OMATP>
138
 <OMA>
139
 <OMS cd="scscp1" name="procedure_completed"/>
140
 <OMI>3628800</OMI>
141
 </OMA>
142
 </OMATTR>
143
</OMOBJ>
144
#I <?scscp end ?>
145
#I Got back: object 3628800 with attributes 
146
[ [ "call_id", "localhost:26133:286:Jok6cQAf" ] ]
147
rec( attributes := [ [ "call_id", "localhost:26133:286:Jok6cQAf" ] ], 
148
 object := 3628800 )
149
gap> SetInfoLevel(InfoSCSCP,0);
150

151

152
153
9.2-2 InfoMasterWorker
154
155
InfoMasterWorker info class
156
157
InfoMasterWorker is a special Info class for the Master-Worker skeleton
158
ParListWithSCSCP (8.2-1). The amount of information to be displayed can be
159
specified by the user by setting InfoLevel for this class from 0 to 5, and
160
the default value of InfoLevel for the package is specified in the file
161
scscp/config.g. The higher the level is, the more information will be
162
displayed. To change the InfoLevel to k, use the command
163
SetInfoLevel(InfoMasterWorker, k). In the following examples we demonstrate
164
various degrees of output details using Info messages.
165
166
Default Info level:
167
168
 Example 
169

170
gap> SetInfoLevel(InfoMasterWorker,2);
171
gap> ParListWithSCSCP( List( [2..6], n -> SymmetricGroup(n)), "WS_IdGroup" );
172
#I 1/5:master --> localhost:26133
173
#I 2/5:master --> localhost:26134
174
#I 3/5:master --> localhost:26133
175
#I 4/5:master --> localhost:26134
176
#I 5/5:master --> localhost:26133
177
[ [ 2, 1 ], [ 6, 1 ], [ 24, 12 ], [ 120, 34 ], [ 720, 763 ] ]
178

179

180
181
Minimal Info level:
182
183
 Example 
184

185
gap> SetInfoLevel(InfoSCSCP,0); 
186
gap> SetInfoLevel(InfoMasterWorker,0);
187
gap> ParListWithSCSCP( List( [2..6], n -> SymmetricGroup(n)), "WS_IdGroup" );
188
[ [ 2, 1 ], [ 6, 1 ], [ 24, 12 ], [ 120, 34 ], [ 720, 763 ] ]
189

190

191
192
Verbose Info level:
193
194
 Example 
195

196
gap> SetInfoLevel(InfoMasterWorker,5); 
197
gap> ParListWithSCSCP( List( [2..6], n -> SymmetricGroup(n)), "WS_IdGroup" );
198
#I 1/5:master --> localhost:26133 : SymmetricGroup( [ 1 .. 2 ] )
199
#I 2/5:master --> localhost:26134 : SymmetricGroup( [ 1 .. 3 ] )
200
#I localhost:26133 --> 1/5:master : [ 2, 1 ]
201
#I 3/5:master --> localhost:26133 : SymmetricGroup( [ 1 .. 4 ] )
202
#I localhost:26134 --> 2/5:master : [ 6, 1 ]
203
#I 4/5:master --> localhost:26134 : SymmetricGroup( [ 1 .. 5 ] )
204
#I localhost:26133 --> 3/5:master : [ 24, 12 ]
205
#I 5/5:master --> localhost:26133 : SymmetricGroup( [ 1 .. 6 ] )
206
#I localhost:26134 --> 4/5:master : [ 120, 34 ]
207
#I localhost:26133 --> 5/5:master : [ 720, 763 ]
208
[ [ 2, 1 ], [ 6, 1 ], [ 24, 12 ], [ 120, 34 ], [ 720, 763 ] ]
209
gap> SetInfoLevel(InfoMasterWorker,2);
210

211

212
213
214
9.3 Other SCSCP Utilities
215
216
9.3-1 DateISO8601
217
218
DateISO8601( )  function
219
Returns: string
220
221
Returns the current date in the ISO-8601 YYYY-MM-DD format. This is an
222
internal function of the package which is used by the SCSCP server to
223
generate the transient content dictionary, accordingly to the definition of
224
the OpenMath symbol meta.CDDate.
225
226
 Example 
227

228
gap> DateISO8601();
229
"2017-02-05"
230

231

232
233
9.3-2 CurrentTimestamp
234
235
CurrentTimestamp( )  function
236
Returns: string
237
238
Returns the result of the call to date. This is an internal function of the
239
package which is used to add the timestamp to the SCSCP service description.
240
241
 Example 
242

243
gap> CurrentTimestamp();
244
"Tue 30 Jan 2017 11:19:38 BST"
245

246

247
248
9.3-3 Hostname
249
250
Hostname( )  function
251
Returns: string
252
253
Returns the result of the call to hostname. This function may be used in the
254
configuration file scscp/config.g to specify that the default hostname which
255
will be used by the SCSCP server will be detected automatically using
256
hostname.
257
258
 Example 
259

260
gap> Hostname();
261
"scscp.gap-system.org"
262

263

264
265
9.3-4 MemoryUsageByGAPinKbytes
266
267
MemoryUsageByGAPinKbytes( )  function
268
Returns: integer
269
270
Returns the current volume of the memory used by GAP in kylobytes. This is
271
equivalent to calling ps -p <PID> -o vsz, where <PID> is the process ID of
272
the GAP process. This is an internal function of the package which is used
273
by the SCSCP server to report its memory usage in the info_memory attribute
274
when being called with the option debuglevel=2 (see options in
275
EvaluateBySCSCP (6.3-1) and NewProcess (6.2-2)).
276
277
 Example 
278

279
gap> MemoryUsageByGAPinKbytes();
280
649848
281

282

283
284
9.3-5 LastReceivedCallID
285
286
LastReceivedCallID( )  function
287
Returns: string
288
289
Returns the call ID contained in the most recently received message. It may
290
contain some useful debugging information; in particular, the call ID for
291
the GAP SCSCP client and server contains colon-separated server name, port
292
number, process ID and a random string.
293
294
 Example 
295

296
gap> LastReceivedCallID();
297
"scscp.gap-system.org:26133:77372:choDZBgA"
298

299

300
301
9.3-6 IO_PickleToString
302
303
IO_PickleToString( obj )  function
304
Returns: string containing "pickled" object
305
306
This function "pickles" or "serialises" the object obj using the operation
307
IO_Pickle (IO: IO_Pickle) from the IO package, and writes it to a string,
308
from which it could be later restored using IO_UnpickleFromString (9.3-7).
309
This provides a way to design SCSCP procedures which transmit GAP objects in
310
the "pickled" format as OpenMath strings, which may be useful for objects
311
which may be "pickled" by the IO package but can not be converted to
312
OpenMath or for which the "pickled" representation is more compact or can be
313
encoded/decoded much faster.
314
315
See IO_Pickle (IO: IO_Pickle) and IO_Unpickle (IO: IO_Unpickle) for more
316
details.
317
318
 Example 
319

320
gap> f := IO_PickleToString( GF( 125 ) );
321
"FFIEINTG\>15INTG\>13FAIL"
322

323

324
325
9.3-7 IO_UnpickleFromString
326
327
IO_UnpickleFromString( s )  function
328
Returns: "unpickled" GAP object
329
330
This function "unpickles" the string s which was created using the function
331
IO_PickleToString (9.3-6), using the operation IO_Unpickle (IO: IO_Unpickle)
332
from the IO package. See IO_PickleToString (9.3-6) for more details and
333
suggestions about its usage.
334
335
 Example 
336

337
gap> IO_UnpickleFromString( f ); 
338
GF(5^3)
339
gap> f = IO_UnpickleFromString( IO_PickleToString( f ) ); 
340
true
341

342

343
344
345