Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Calling Mathematica via MathLink multiple times

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44713] Re: Calling Mathematica via MathLink multiple times
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 22 Nov 2003 02:17:09 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <bpkqfk$cjr$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

why do you not keep the connection alive ?

Your process launch (as a child process) the Mathematica kernel,
the most operating systems terminate child processes when the
calling process terminates. To hinder this you must launch
the child process in a operating system specific way -- not
with LinkOpen(). 

If you have done that, your calling process can terminate
but you have no way to tell the still runing Mathematica
kernel that it should connect to an other process.
The only exeception would be that the calling process
launches a second child process and tell the Mathematica
kernel that it should connect to that second process.

So keep the connection to the kernel alive ...

Regards
  Jens


Julius Su wrote:
> 
> Hello,
> 
>   I would to call Mathematica from within a C program to evaluate a
> lengthy function.  (the reverse of the usual situation!)
> 
>   To do this I am using MathLink, and I have written a test program
> that successfully establishes a link with the kernel, calls the
> function, and returns the answer.  When the program exits though, the
> link to the kernel dies and the kernel quits.
> 
>   Is there any way to keep the kernel alive between MathLink
> connections? This would be useful for storing persistent information,
> and for avoiding reinitializing certain routines before each function
> call.
> 
> Possible (indirect) solutions:
> 1.  I have used <<JLink` and the ShareKernel[] command to allow the
> kernel to switch between multiple links, but I would then need a way
> to (1) detect when connections are broken and create a new link and
> (2) tell my C program which port to connect under.
> 2.  I could set up a program that connects once to the Mathematica
> kernel, then write another program that contacts the first via a
> message queue and semaphores.  There must be a simpler way though!
> 
> Thanks,
> 
> Julius


  • Prev by Date: Remote Display on Linux still unsolved !
  • Next by Date: RE: Re: Open and Close Groups, *one level at a time*?
  • Previous by thread: Calling Mathematica via MathLink multiple times
  • Next by thread: Re: Calling Mathematica via MathLink multiple times