Message Boards Message Boards

Creation of a persistent WSTP application?

Posted 8 years ago

I have written numerous WSTP applications that take data from Mathematica, manipulate it in combination with data retrieved from other sources, and then return it to Mathematica. See for example https://github.com/MichaelSternNYC

All of these have been set up for a single interaction -- Mathematica calls wstpfunction[var1_Integer, var2_Integer] (or whatever) and this is received within C++ as void wstpfunction(int var1, int var2) (or whatever). The C++ code does what it needs to and then returns data to Mathematica with WSPutString() or one of its sister functions. The C++ application then terminates, though the WSTP link can be left installed, which speeds things up if wstpfunction[] is called again. Though the link remains valid, the program stops running after returning it output and must be restarted when called again. This is important because the value of any static variables is lost between calls.

My current task involves repeated use of a subscription to an outside data service, and I need certain information to remain resident in the WSTP program between calls. How might one craft a WSTP program that doesn't quit until asked, and which can accept new input from Mathematica at any time?

POSTED BY: Michael Stern
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract