  
  [1X7 Examples of [5XSCSCP[1X usage[0X
  
  In  this  chapter we are going to demonstrate some examples of communication
  between client and server using the SCSCP.
  
  
  [1X7.1 Providing services with the SCSCP package[0X
  
  You   can   try  to  run  the  SCSCP  server  with  the  configuration  file
  [11Xscscp/example/myserver.g[0m.  To  do  this,  go to that directory and enter [10Xgap
  myserver.g[0m.  After  this  you will see some information messages and finally
  the  server  will  start  to  wait for the connection. The final part of the
  startup screen may look as follows:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4X#I  Installed SCSCP procedure Factorial[0X
    [4X#I  Installed SCSCP procedure WS_Factorial[0X
    [4X#I  Installed SCSCP procedure GroupIdentificationService[0X
    [4X#I  Installed SCSCP procedure IdGroup512ByCode[0X
    [4X#I  Installed SCSCP procedure WS_IdGroup[0X
    [4X#I  Installed SCSCP procedure WS_Karatsuba[0X
    [4X#I  Installed SCSCP procedure EvaluateOpenMathCode[0X
    [4X#I  Ready to accept TCP/IP connections at localhost:26133 ...[0X
    [4X#I  Waiting for new client connection at localhost:26133 ...[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  See  further self-explanatory comments in the file [11Xscscp/example/myserver.g[0m.
  There  also  some  test  files  in  the  directory  [11Xscscp/tst/[0m supplied with
  detailed  comments.  First,  you  may  use  demonstration files, preliminary
  turning on the demonstration mode as it is explained in these files, or just
  executing   step   by   step   each   command   from   [11Xscscp/tst/demo.g[0m  and
  [11Xscscp/tst/omdemo.g[0m.  Then  you  can  try  to  use  files  [11Xscscp/tst/id512.g[0m,
  [11Xscscp/tst/idperm.g[0m   and  [11Xscscp/tst/factor.g[0m  for  further  tests  of  [5XSCSCP[0m
  services.
  
  
  [1X7.2 Identifying groups of order 512[0X
  
  We  will  give  an example guiding you through all steps of creation of your
  own [5XSCSCP[0m service.
  
  The  [5XGAP[0m  Small  Group Library does not provide identification for groups of
  order 512 using the function [10XIdGroup[0m:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> IdGroup( DihedralGroup( 256 ) );[0X
    [4X[ 256, 539 ][0X
    [4Xgap> IdGroup(DihedralGroup(512)); [0X
    [4XError, the group identification for groups of size [0X
    [4X512 is not available called from[0X
    [4X<function>( <arguments> ) called from read-eval-loop[0X
    [4XEntering break read-eval-print loop ...[0X
    [4Xyou can 'quit;' to quit to outer loop, or[0X
    [4Xyou can 'return;' to continue[0X
    [4Xbrk> [0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  However,     the    [5XGAP[0m    package    [5XANUPQ[0m    [GNO]    has    a    function
  [10XIdStandardPresented512Group[0m that does this work as demonstrated below:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> LoadPackage("anupq");[0X
    [4X-------------------------------------------------------------[0X
    [4XLoading ANUPQ 3.0 (ANU p-Quotient package)[0X
    [4XC code by  Eamonn O'Brien <obrien@math.auckland.ac.nz>[0X
    [4X           (ANU pq binary version: 1.8)[0X
    [4XGAP code by Werner Nickel <nickel@mathematik.tu-darmstadt.de>[0X
    [4X        and   Greg Gamble  <gregg@math.rwth-aachen.de>[0X
    [4X[0X
    [4X            For help, type: ?ANUPQ[0X
    [4X-------------------------------------------------------------[0X
    [4Xtrue[0X
    [4Xgap> G := DihedralGroup( 512 );            [0X
    [4X<pc group of size 512 with 9 generators>[0X
    [4Xgap> F := PqStandardPresentation( G );[0X
    [4X<fp group on the generators [ f1, f2, f3, f4, f5, f6, f7, f8, f9 ]>[0X
    [4Xgap> H := PcGroupFpGroup( F );[0X
    [4X<pc group of size 512 with 9 generators>[0X
    [4Xgap> IdStandardPresented512Group( H );[0X
    [4X[ 512, 2042 ][0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  The  package [5XANUPQ[0m requires [5XUNIX[0m environment and it is natural to provide an
  identification  service  for  groups  of  order 512 to make it available for
  other platforms.
  
  Now  we  need  to decide how the client will transmit a group to the server.
  Can we encode this group in [5XOpenMath[0m? But there is no content dictionary for
  PcGroups. Should we convert it to a permutation representation to be able to
  use existing content dictionaries? But then the resulting [5XOpenMath[0m code will
  be  not compact. However, the [5XSCSCP[0m protocol provides enough freedom for the
  user  to  select  its  own  data  representation,  and  since we are linking
  together two copies of the same system, we may use the [13Xpcgs code[0m to pass the
  data to the server (see [2XCodePcGroup[0m ([14XReference: CodePcGroup[0m).
  
  First we create a function which accepts the integer number that is the code
  for pcgs of a group of order 512 and returns the number of this group in the
  GAP Small Groups library:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4XIdGroup512ByCode := function( code )[0X
    [4Xlocal G, F, H;[0X
    [4XG := PcGroupCode( code, 512 );[0X
    [4XF := PqStandardPresentation( G );
H := PcGroupFpGroup( F );
return IdStandardPresented512Group( H );[0X
    [4Xend;[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  After  such function was created on the server, we need to make it "visible"
  as an [5XSCSCP[0m procedure:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> InstallSCSCPprocedure("IdGroup512", IdGroup512ByCode );[0X
    [4XInstallSCSCPprocedure : procedure IdGroup512 installed. [0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  Note  that  this function assumes that the argument is a valid code for some
  group  of order 512, and we wish the client to make it sure that this is the
  case.  To  do  this,  and  also for the client's convenience, we provide the
  client's  counterpart for this service. Here the group must be a pc-group of
  order 512, otherwise an error message will appear.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4XIdGroup512:=function( G )[0X
    [4Xlocal code, result;[0X
    [4Xif Size( G ) <> 512 then[0X
    [4X  Error( "G must be a group of order 512 \n" );[0X
    [4Xfi;[0X
    [4Xcode := CodePcGroup( G );[0X
    [4Xresult := EvaluateBySCSCP( "IdGroup512ByCode", [ code ], [0X
    [4X                           "localhost", 26133 );[0X
    [4Xreturn result.object;[0X
    [4Xend;[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  Now  the  client  can  call  the  function  [10XIdGroup512[0m, and the procedure of
  getting  result is as much straightforward as using [10XIdGroup[0m for those groups
  where it works:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> IdGroup512(DihedralGroup(512));[0X
    [4X#I  Creating a socket ...[0X
    [4X#I  Connecting to a remote socket via TCP/IP ...[0X
    [4X#I  Got connection initiation message[0X
    [4X#I  Request sent ...[0X
    [4X#I  Waiting for reply ...[0X
    [4X[ 512, 2042 ][0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
