Transferring Data

Event

lgo_Event()

Read a waiting control event.

Syntax
#include "laygo.h"

LEvent  lgo_Event
    (
        LCid             cid,
        LCtlBuffer       buffer,
        LBufferSize *    size
    );
cidconnection to read a non-data event from
bufferbuffer for protocol-specific data returned with event
sizesize of buffer on input
size of data in buffer on output
Description

lgo_Event() reads non-data events which have occurred on the connection. lgo_Poll() can be used to poll a connection for control events and/or data, but control events can only be read using lgo_Event().

Return Values

If successful, lgo_Event() returns a non-negative event identifier indicating the type of control event received. Possible successful return values are:

Otherwise, it returns a negative value indicating the reason it failed. Possible unsuccessful return values are:

See Also

lgo_Poll()

Example
if ((event = lgo_Poll(cid, &bufferSize)) < 0)
{
    /* process error */
}
else
{
    switch(event)
    {
        case lgo_EVENT_DATA_OK:

            /* read good data */
            break;

        case lgo_EVENT_DATA_LENGTH_ERROR:
        case lgo_EVENT_DATA_CRC_ERROR:
        case lgo_EVENT_DATA_ABORTED_FRAME:

            /* discard bad data */
            break;

        default:

            lgo_Event(cid, buffer, &bufferCapacity);
            /* process any event data */
            break;
    }
}