Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Documentation / Mathematica / Add-ons & Links / J/Link / Part 2. Writing Java Programs That Use Mathematica / Sending Computations and Reading Results /

2.8.1 MathLink Packets

Communication with the Mathematica kernel generally takes place in the form of "packets." A MathLink packet is just a Mathematica function, albeit one from a set that is recognized and treated specially by MathLink. When you send something to Mathematica to be evaluated, you wrap it in a packet that tells Mathematica that this is a request for something to be computed, and also tells something about how it is to be computed. All output you receive from Mathematica, including the result and any other side effect output like messages, Print output, and graphics, will also arrive wrapped in a packet. The type of packet tells you about the contents.

A MathLink program typically sends a computation to Mathematica wrapped in a special packet, and then reads a succession of packets arriving from the kernel until the one containing the result of the computation arrives. Along the way, packets that do not contain the result can be either discarded without bothering to examine them or they can be "opened" and operated on. Such nonresult packets include TextPackets containing Print output, MessagePackets containing Mathematica warning messages, DisplayPackets containing PostScript, and several other types.

You can look at existing MathLink documentation for information on the various packet types for sending things to Mathematica and for what Mathematica sends back. In particular, you should look at this author's MathLink Tutorial (http://www.mathsource.com/Content/Enhancements/MathLink/0206-693). For most uses, J/Link hides all the details of packet types and how to send and receive them. You only need to read about packet types if you want to do something beyond what the built-in behavior of J/Link provides. This can be useful for many programs.



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information


 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy | [ja] |
Sign up for our newsletter: