Wolfram Language & System 10.0 (2014)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

This feature is not supported on the Wolfram Cloud.

int WSNextPacket(WSLINK link)
goes to the next packet on link and returns a constant to indicate its head.


  • The following packets can be returned:
  • BEGINDLGPKTBeginDialogPacket[integer]start a dialog subsession referenced by integer
    CALLPKTCallPacket[integer,list]request to invoke the external function numbered integer with arguments list
    DISPLAYENDPKTDisplayEndPacket[]obsolete PostScript graphics-related packet
    DISPLAYPKTDisplayPacket[]obsolete PostScript graphics-related packet
    ENDDLGPKTEndDialogPacket[integer]end the dialog subsession referenced by integer
    ENTEREXPRPKTEnterExpressionPacket[expr]evaluate expr
    ENTERTEXTPKTEnterTextPacket[string]parse string and evaluate as an expression
    EVALUATEPKTEvaluatePacket[expr]evaluate expr while avoiding the kernel main loop
    INPUTNAMEPKTInputNamePacket[string]name to be assigned to the next input (usually In[n]:=)
    INPUTPKTInputPacket[]prompt for input, as generated by the Wolfram Language's Input[] function
    INPUTSTRPKTInputStringPacket[]request input as a string
    MENUPKTMenuPacket[integer,string]menu request with title string
    MESSAGEPKTMessagePacket[symbol,string]Wolfram Language message identifier ()
    OUTPUTNAMEPKTOutputNamePacket[string]name to be assigned to the next output (usually Out[n]=)
    RESUMEPKTResumePacket[]obsolete packet
    RETURNEXPRPKTReturnExpressionPacket[expr]result of EnterExpressionPacket[] evaluation
    RETURNPKTReturnPacket[expr]result of a calculation
    RETURNTEXTPKTReturnTextPacket[string]formatted text representation of a result
    SUSPENDPKTSuspendPacket[]obsolete packet
    SYNTAXPKTSyntaxPacket[integer]position at which a syntax error was detected in the input line
    TEXTPKTTextPacket[string]text output from the Wolfram Language, as produced by Print[]
  • WSNextPacket() returns ILLEGALPKT in the event of an error. wstp.h defines ILLEGALPKT as 0.
  • WSNextPacket() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

/* read the type of the incoming packet on a link */

void f(MLINK lp)
        case CALLPKT:
            /* read the CallPacket[] */
        case EVALUATEPKT:
            /* read the EvaluatePacket[] */
        case RETURNPKT:
            /* read the EvaluatePacket[] */

        /* ... */

        case ILLEGALPKT:
            /* unable to read the next packet from lp */