Transferring Data

Read Next

lgo_ReadNext()

Read next available data on any CID or report nondata event on a CID.

Syntax
#include "laygo.h"

LResult lgo_ReadNext
    (
        LCid *         cid,
        LDataBuffer    buffer,
        LBufferSize    size
    );
cidoutput for cid data read from
bufferbuffer to receive data into
sizesize of receive buffer in bytes
Description

lgo_ReadNext() scans all connections looking for data and nondata events. If data is found on a connection, it will be returned provided the buffer is large enough. If the connection has more than one data event waiting, subsequent calls will read all this data before moving on to another connection. If a nondata event is encountered, lgo_ERROR_EVENT_WAITING will be returned and the CID with the nondata event will be returned through the output parameter, but no action will be taken for that event. However, if lgo_ReadNext() is called again, it will return data or nondata events from other connections in its list. It will return lgo_ERROR_EVENT_WAITING on the same connection twice in a row only if there are no other connections at all with any events waiting. Use lgo_Event() to handle nondata events on a connection.

If lgo_ReadNext() fails with an error code of lgo_ERROR_BUFFER_SIZE, the application may call lgo_Poll() to determine the number of bytes of data waiting to be read.

Return Values

If successful, lgo_ReadNext() returns a non-negative value indicating the number of bytes read into the buffer. Otherwise, it returns a negative value indicating the reason it failed. Possible unsuccessful return values are:

A return value of 0 means that there are no data or control events waiting to be read on any connection.

See Also

lgo_Event()
lgo_Poll()

Example
if (lgo_ReadNext(&cid, buffer, size) < 0)
{
    /* process error */
}
else
{
    /* process data */
}