IMathLink Interface

IMathLink is the low-level interface that is the root of all link objects in .NET/Link. The methods in IMathLink correspond roughly to a subset of those in the C-language WSTP API.

Definition

Namespace: Wolfram.NETLink
Assembly: Wolfram.NETLink (in Wolfram.NETLink.dll) Version: 2.0.0.0
C#
public interface IMathLink

Remarks

Most programmers will deal instead with objects of type IKernelLink, a higher-level interface that extends IMathLink and incorporates the assumption that the program on the other side of the link is a Wolfram kernel.

You create objects of type IMathLink via the CreateMathLink method. Again, though, most programmers will use IKernelLink instead of IMathLink.

Most IMathLink methods throw a MathLinkException if a link-related error occurs. Examples would be calling EndPacket before sending a complete expression, or calling GetFunction when an integer is waiting on the link.

For additional information about these methods, see the .NET/Link User Guide, and also the documentation for Wolfram's WSTP protocol (formerly known as MathLink). Most of these IMathLink methods are substantially similar, if not identical, to their C counterparts as documented in the WSTP API, which .NET/Link uses internally.

Properties

ComplexType Sets or gets the class that you want to map to Wolfram Language Complex numbers.
Error Gets the current error state for the link.
ErrorMessage Gets a textual message describing the current error state for the link.
Name Gets the name of the link.
Ready Indicates whether the link has data waiting to be read.

Methods

BytesToGet Gives the number of bytes that remain to be read in the element that is currently being read in textual form.
BytesToPut Gives the number of bytes that remain to be sent in the element that is currently being sent in textual form.
CheckFunction Reads a function name and argument count and requires that it match the specified function name.
CheckFunctionWithArgCount Reads a function name and argument count and requires that it match the specified function name and arg count.
ClearError Clears the link error condition, if possible.
Close Closes the link.
Connect Waits for the link to be connected.
Connect(Int64) Waits for the link to be connected for at most the specified number of milliseconds before throwing a MathLinkException.
CreateMark Creates a mark at the current point in the incoming MathLink data stream.
DestroyMark Destroys a mark.
DeviceInformation A low-level function that retrieves special internal information from the MathLink device.
EndPacket Call when you are finished writing the contents of a single packet.
Flush Immediately transmits any data buffered for sending over the link.
GetArgCount Reads the argument count of an expression being read manually.
GetArray(Type, Int32) Reads an array and discards information about the heads at each level.
GetArray(Type, Int32, String) Reads an array and records information about the heads at each level.
GetBoolean Reads the Wolfram Language symbols True or False as a bool.
GetBooleanArray Reads a list as a one-dimensional array of bools.
GetByteArray Reads a list as a one-dimensional array of bytes.
GetByteString Reads a Wolfram Language string as an array of bytes.
GetCharArray Reads a list as a one-dimensional array of chars.
GetComplex Reads a complex number. This can be an integer, real, or a Wolfram Language expression with head Complex.
GetComplexArray Reads a list as a one-dimensional array of complex numbers.
GetData Gets a specified number of bytes in the textual form of the expression currently being read.
GetDecimal Reads a Wolfram Language integer or real number or integer as a decimal.
GetDecimalArray Reads a list as a one-dimensional array of decimals.
GetDouble Reads a Wolfram Language real number or integer as a double.
GetDoubleArray Reads a list as a one-dimensional array of doubles.
GetExpr Reads an arbitrary expression from the link and creates an Expr from it.
GetExpressionType Gives the type of the current element in the expression currently being read.
GetFunction Reads a function name and argument count.
GetInt16Array Reads a list as a one-dimensional array of shorts.
GetInt32Array Reads a list as a one-dimensional array of ints.
GetInt64Array Reads a list as a one-dimensional array of longs.
GetInteger Reads a Wolfram Language integer as a 32-bit integer.
GetNextExpressionType Gives the type of the next element in the expression currently being read.
GetObject Reads a single expression off the link and returns an appropriate object.
GetSingleArray Reads a list as a one-dimensional array of floats.
GetString Reads a Wolfram Language character string.
GetStringArray Reads a list as a one-dimensional array of strings.
GetStringCRLF Reads a Wolfram Language character string and translates newlines into Windows format.
GetSymbol Reads a Wolfram Language symbol as a string.
NewPacket Discards the current packet, if it has been partially read. Has no effect if the previous packet was fully read.
NextPacket "Opens" the next packet arriving on the link.
PeekExpr Creates an Expr from the current expression, but does not drain it off the link.
Put(Boolean) Sends a bool value as the Wolfram Language symbol True or False.
Put(Decimal) Sends a decimal value as an integer or real.
Put(Double) Sends a double value.
Put(Int32) Sends an integer value.
Put(Int64) Sends a long integer value.
Put(Object) Sends an object, including strings and arrays.
Put(Array, String) Sends an array object. Unlike Put(object), this method lets you specify the heads you want for each dimension.
PutArgCount Specifies the argument count for a composite expression being sent manually.
PutData Used for sending elements in so-called "textual" form.
PutFunction Sends a function name and argument count.
PutFunctionAndArgs Sends a function name and its arguments.
PutMessage Sends a low-level MathLink message.
PutNext Identifies the type of data element that is to be sent next.
PutSize Specifies the size in bytes of an element being sent in textual form.
PutSymbol Sends a symbol.
SeekMark Resets the current position in the incoming MathLink data stream to an earlier point.
TransferExpression Reads a complete expression from the named link and writes it to this link.
TransferToEndOfLoopbackLink Reads the entire contents of a loopback link and writes it to this link.

Events

MessageArrived Occurs when a low-level MathLink message arrives.
Yield Occurs periodically when the link is blocking in a reading call.

See Also