Transferring Data



Read data from a connection.

#include "laygo.h"

LResult lgo_Read
        LCid           cid,
        LDataBuffer    buffer,
        LBufferSize    size
cidconnection tp read on
bufferbuffer to receive data into
sizesize of receive buffer in bytes

lgo_Read() reads data from a connection. The minimum and maximum number of bytes which can be requested in one call to lgo_Read() is a system parameter defined by the configuration of the buffer pool and the protocols used.

If lgo_Read() 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_Read() 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 neither data nor control events waiting to be read.

See Also


if ((bytesRead = lgo_Read(cid, buffer, size)) < 0)
    /* process error */
else if (bytesRead > 0)
    /* process read data */
    /* process other CIDs */