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

4.8.5.2 MPtcp links

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

listen
SINGULAR acts as a server.

connect
SINGULAR acts as a client.

launch
SINGULAR acts as a client, launching an application as server.

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

The MPtcp link describing string has to be

  • listen mode:
    1. "MPtcp:listen --MPport " + portnumber
    SINGULAR becomes a server and waits at the port for a connect call.
  • connect mode:
    1. "MPtcp:connect --MPport " + portnumber
    2. "MPtcp:connect --MPhost " + hostname + " --MPport " + portnumber
    SINGULAR becomes a client and connects to a server waiting at the host and port.
  • launch mode:
    1. "MPtcp:launch"
    2. "MPtcp:launch --MPrsh " + rsh
    3. "MPtcp:launch --MPrsh " + rsh + " --MPhost " + hostname
    4. "MPtcp:launch --MPrsh " + rsh + " --MPhost " + hostname + " --MPapplication " + application
    SINGULAR becomes a client and starts (launches) the application using the specified remote shell command (default is ssh) on a (possibly) different host (default is localhost which then acts as a server.
  • fork mode:
    1. "MPtcp:fork"
    SINGULAR becomes a client and forks another SINGULAR on the same host which acts as a server.

There are the following default values:

  • if none of listen, connect, launch or fork is specified, the default mode is set to fork.

  • if no remote shell (rsh) command is specified, then the command ssh is used.

  • if no application is specified in mode launch the default application is the value of system("Singular") + "-bq". (This evaluates to the absolute path of the SINGULAR currently running with the option "-bq" appended.)

  • if no hostname is specified the local host is used as default host.

To open an MPtcp 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. SINGULAR automatically appends the command line arguments "--MPmode connect --MPhost hostname --MPport portnumber" to the command line of the server application. Both hostname and portnumber are substituted by the values from the link specification. The client "listens" at the given port until the server application does a connect call. If SINGULAR is used as server application it has to be started with the command line option -b. Since launching is done using a remote shell command, the host on which the application should run must have an entry in the .rhosts file. Even the local machine must have an entry if applications are to be launched locally.

If the MPtcp 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 MPtcp 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.

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


Example:
 


Top Back: MPfile links Forward: Ssi links FastBack: ASCII links FastForward: Ssi links Up: MP links Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 3-1-6, Dec 2012, generated by texi2html.