MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

MathLink portnumbers and internal types

  • To:
  • Subject: [mg10937] MathLink portnumbers and internal types
  • From: (Stefan Berglund)
  • Date: Sat, 14 Feb 1998 00:53:13 -0500
  • Organization: Engineering Physics, Chalmers University of Technologhy

I wish to have a process to communicate via mathlink peer to peer to a
remote computer.  The problem is that I a start new mathlink
connections as needed from forked processes and I have found no way of
telling wich portnumber has been chosen.

The problem will probably be solved if I knew how the internal mathlink
types MLINK (struct MLink) and MLENV (struct ml_environment) is
constructed, the info should be in them.  I have searched the online
help, The Mathematica book and the mathlink tutorial. I have looked in
mathlink.h, mprep generated code and from the debugger.  The simple
answer is that these types is hidden inside the libML.a library file.

I have also seen references to the MathLink Reference but where do I
find such a creature (if its not the one in The Book). I do desperatly
hope for a real reference with all functions, types and description of
error status and so on.  All official documentation I have read so far
leaves a _lot_ to be desired.

The outline of my system is:


Mathematica end:

(* Install main link *)
link=Install["", LinkMode->Connect] (* Read data of new
link that will be used after this *) newlink=LinkRead[link]
(* Close main link *)
(* Setup communication link *)
(* I will of course have to rebuild the newlink data at  some end so
that Install will accept it *) comlink=Install[newlink, LinkMode ->
(* Close remote process *)
(* Uninstall communication link *)


Parent process:

/* Init Mathlink */
/* Open up first link */
link=MLOpenString(stdenv, "-linkname 12345 -linkcreate", &err);

while(1) {
   /* Wait for connection on first link */

   /* Spawn a subprocess */
   if(pid) {
      exec("childprocess 12345");


Child process:
/* Init mathlink */

/* Open communication link to mathematica */ commlink=MLOpenString(env,
"-linkcreate", &err);

/* Tell mathematica the port I got but */ /* how do I know which port
that is? */ MLPutString(link, commlink);  

/* Wait for connection */

/* Read communication link */
while(1) {
   switch(MLGetNext(commlink)) {


I will be very grateful for any pointers!


Life - the ultimate practical joke

finger for public pgp-key

  • Prev by Date: Re: Can anyone help me with these?
  • Next by Date: Re: Debug program
  • Prev by thread: Re: How do you draw Triangles and other Geometric figures in Mathematica?
  • Next by thread: Re: MathLink portnumbers and internal types