WSFlush (C Function)

int WSFlush(WSLINK link)

flushes out any buffers containing data waiting to be sent on link.

Details

  • If you call WSNextPacket() or any of the WSGet functions, then WSFlush() will be called automatically.
  • If you call 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 WSError() to retrieve the error code if WSFlush() fails.
  • WSFlush() is declared in the WSTP header file wstp.h.

Examples

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 */ }
}