OpenersNotesSection(Spacer1)Details

The following packets can be returned:

MLNextPacket() returns ILLEGALPKT in the event of an error. (RefLink[mathlink.h, paclet:ref/file/mathlink.h]) defines ILLEGALPKT as 0.

MLNextPacket() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

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

void f(MLINK lp)
{
	switch(MLNextPacket(lp))
	{
		case CALLPKT:
			/* read the CallPacket[] */
			break;
		case EVALUATEPKT:
			/* read the EvaluatePacket[] */
			break;
		case RETURNPKT:
			/* read the EvaluatePacket[] */

		/* ... */

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

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLNewPacket(), paclet:ref/c/MLNewPacket])}})}})