Top
Back: Ssi file links
Forward: Pipe links
FastBack: ASCII links
FastForward: Pipe links
Up: Ssi links
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.8.5.2 Ssi tcp links

Ssi tcp links give the possibility to exchange data between two processes which may run on the same or on different computers. Ssi tcp links can be opened in four different modes:

tcp
SINGULAR acts as a server.

connect
SINGULAR acts as a client.

tcp <host>:<program>
SINGULAR acts as a client, launching an application as server.

fork
SINGULAR acts as a client, forking another SINGULAR as server.

The Ssi tcp link describing string has to be

  • tcp mode:
    1. "ssi:tcp"
    SINGULAR becomes a server and waits at the first free port (>1024) for a connect call.
  • connect mode:
    1. "ssi:connect " + host:port
    SINGULAR becomes a client and connects to a server waiting at the host and port.
  • launch mode:
    1. "ssi:tcp" + host:application
    SINGULAR becomes a client and starts (launches) the application using ssh on a (possibly) different host which then acts as a server.
  • fork mode:
    1. "ssi:fork"
    SINGULAR becomes a client and forks another SINGULAR on the same host which acts as a server.

To open an ssi tcp link in launch mode, the application to launch must either be given with an absolute pathname, or must be in a directory contained in the search path. The launched application acts as a server, whereas the SINGULAR that actually opened the link acts as a client. The client "listens" at the some free port until the server application does a connect call.

If the ssi tcp link is opened in fork mode a child of the current SINGULAR is forked. All variables and their values are inherited by the child. The child acts as a server whereas the SINGULAR that actually opened the link acts as a client.

To arrange the evaluation of an expression by a server, the expression must be quoted using the command quote (see quote), so that a local evaluation is prevented. Otherwise, the expression is evaluated first, and the result of the evaluation is written, instead of the expression which is to be evaluated.

If SINGULAR is in server mode, the value of the variable link_ll is the ssi link connecting to the client and SINGULAR is in an infinite read-eval-write loop until the connection is closed from the client side (by closing its connecting link). Reading and writing is done to the link link_ll: After an expression is read, it is evaluated and the result of the evaluation is written back. That is, for each expression which was written to the server, there is exactly one expression written back. This might be an "empty" expression, if the evaluation on the server side does not return a value.

Ssi tcp links should explicitly be opened before being used. Ssi tcp links are bidirectional, i.e. can be used for both, writing and reading. Reading from an ssi tcp link blocks until data was written to that link. The status command can be used to check whether there is data to read.


Example:
 
  int i=7;
  link l = "ssi:fork";      // fork link declaration
  open(l); l;
==> // type : ssi
==> // mode : fork
==> // name : 
==> // open : yes
==> // read : not ready
==> // write: ready

  write(l,quote(i)); // Child inherited vars and their values
  read(l);
==> 7
  close(l);          // shut down forked child


Top Back: Ssi file links Forward: Pipe links FastBack: ASCII links FastForward: Pipe links Up: Ssi links Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 4-0-3, 2016, generated by texi2html.