|
4.6.5.2 MPtcp linksMPtcp 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:
The MPtcp link describing string has to be
There are the following default values:
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
" 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 If SINGULAR is in server mode, the value of the variable
MPtcp links should explicitly be opened before being used. MPtcp links
are bidirectional, i.e., can be be used for both, writing and
reading. Reading from an MPtcp link blocks until data was written to
that link. The Example: LIB "general.lib"; // needed for "killall" command
link l="MPtcp:launch";
open(l); l; // l is ready for writing but not for reading
→ // type : MPtcp
→ // mode : launch
→ // name :
→ // open : yes
→ // read : not ready
→ // write: ready
ring r; ideal i=x2+y,xyz+z,x2+y2;
write (l,quote(std(eval(i)))); // std(i) is computed on server
def j = read(l);j; // result of computation on server is read
→ j[1]=z
→ j[2]=y2-y
→ j[3]=x2+y2
write(l, quote(getdump(mp_ll))); // server reads dump
dump(l); // dump is written to server (includes proc's)
read(l); // result of previous write-command is read
killall("not", "link"); killall("proc"); // kills everything, but links
→ // ** killing the basering for level 0
write(l, quote(dump(mp_ll))); // server writes dump
getdump(l); // dump is read from server
read(l); // result of previous write-command is read
close(l); // server is shut down
listvar(all); // same state as we had before "killall()"
→ // mpsr_r0 [0] ring
→ // r [0] *ring
→ // j [0] ideal, 3 generator(s)
→ // i [0] ideal, 3 generator(s)
→ // l [0] link
l = "MPtcp:"; // fork link declaration
open(l); l; // Notice that name is "parent"
→ // type : MPtcp
→ // mode : fork
→ // name : parent
→ // open : yes
→ // read : not ready
→ // write: ready
write(l, quote(status(mp_ll, "name")));
read(l); // and name of forked link is "child"
→ child
write(l,quote(i)); // Child inherited vars and their values
read(l);
→ _[1]=x2+y
→ _[2]=xyz+z
→ _[3]=x2+y2
close(l); // shut down forked child
|
| |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |