WSReady (C Function)

int WSReady(WSLINK link)

tests whether there is data ready to be read from link.

Details

  • Analogous to the Wolfram Language function LinkReadyQ.
  • WSReady() is often called in a loop as a way of polling a WSTP connection.
  • WSReady() will always return immediately, and will not block.
  • If you have written data to the link, you must call WSFlush() before calling WSReady().
  • WSReady() returns 0 if the link has no data to read and a nonzero value if the link does have data.
  • If link has not been activated, then WSReady() returns 0 if the other side of the link has not been created.
  • WSReady() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* check a link for readable data */

void f(WSLINK lp);
{
    if(! WSFlush(lp))
        { /* unable to flush any outgoing data buffered in lp */ }

    if(WSReady(lp))
        { /* read the data from the link */ }
    else
        { /* data not ready to read */ }
}