MathGroup Archive 1999

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

Search the Archive

Re: Q: How to specify the port and the host in a MathLink-Program?

  • To: mathgroup at
  • Subject: [mg21328] Re: Q: How to specify the port and the host in a MathLink-Program?
  • From: "P.J. Hinton" <paulh at>
  • Date: Fri, 24 Dec 1999 03:42:30 -0500 (EST)
  • Organization: "Wolfram Research, Inc."
  • References: <83po7n$>
  • Sender: owner-wri-mathgroup at

On 22 Dec 1999, Claudius Schnörr wrote:

> I would like to run a C-program on a Solaris-machine communicating with the
> math-kernel on a PC.
> Is this possible?

Yes, it is possible, provided that you can establish a TCP/IP-based
connection between the machines.

You do not say what operating system is running on the PC.  If it some
variant of Windows, you will have to launch the kernel from a command
prompt window while physically sitting at the machine.  It is also
possible to set up an rsh service on the PC so that you can invoke the
command line for launching the kernel from your C program.  This requires
an add-on utility and is beyond the scope of this newsgroup.  You should
also keep in mind that setting up an rsh service on the PC may expose you
to security risks.

> How can I specify the host and the port to be used by the
> MathLink-C-program on Unix and the math-kernel on the PC?

These functions serve the same purpose -- opening a MathLink connection --
but their inputs are different.  MLOpenString() requires that the flags
used to specify the link are stored as one contiguous string.
MLOpenArgv() requires each argument be stored in its own string.  You can
specify the port number only for the side that is listening.  If you plan
to have the C program begin by listening, you will need to supply the

-linkprotocl "TCP"
-linkname "<port number>"

When you supply the command to launch the kernel from the command prompt,
it should look like

math -mathlink -linkconnect -linkprotocol "TCP" -linkname "<portnumber>@<hostname>"

P.J. Hinton
Mathematica Programming Group           paulh at
Wolfram Research, Inc.

  • Prev by Date: Re: Re: serie of random number
  • Next by Date: computing Dickman's function
  • Previous by thread: Q: How to specify the port and the host in a MathLink-Program?
  • Next by thread: from Graphics3D to 2D