This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

MLReady()

int MLReady(MLINK link)
tests whether there is data ready to be read from link.
  • Analogous to the Mathematica function LinkReadyQ.
  • MLReady() is often called in a loop as a way of polling a MathLink connection.
  • MLReady() will always return immediately, and will not block.
  • You must call MLFlush() before calling MLReady().
  • MLReady() returns 0 if the link has no data to read and a nonzero value if the link does have data.
  • MLReady() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* check a link for readable data */

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

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