OpenersNotesSection(Spacer1)Details

If you call (NonWLLink[WSNextPacket(), paclet:ref/c/WSNextPacket]) or any of the WSGet functions, then WSFlush() will be called automatically.

If you call (NonWLLink[WSReady(), paclet:ref/c/WSReady]), then you need to call WSFlush() first in order to ensure that any necessary outgoing data has been sent.

WSFlush() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[WSError(), paclet:ref/c/WSError]) to retrieve the error code if WSFlush() fails.

WSFlush() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

/* send the expression Integrate[1/x^2,x] to a link */

void f(WSLINK lp)
{
	if(! WSPutFunction(lp, "EvaluatePacket", 1))
		{ /* unable to put the function to lp */ }

	if(! WSPutFunction(lp, "ToExpression", 1))
		{ /* unable to put the function to lp */ }

	if(! WSPutString(lp, "Integrate[1/x^2, x]"))
		{ /* unable to put the string to lp */ }

	if(! WSEndPacket(lp))
		{ /* unable to put the end of packet indicator to lp */ }

	if(! WSFlush(lp))
		{ /* unable to flush the buffered data in lp */ }
}

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Running the Wolfram System from within an External Program, paclet:tutorial/RunningTheWolframSystemFromWithinAnExternalProgram])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[Low-Level WSTP Operations, paclet:guide/LowLevelWSTPOperations])}})}})