Transferring Data
lgo_Read()
Read data from a connection.
#include "laygo.h"
LResult lgo_Read
(
LCid cid,
LDataBuffer buffer,
LBufferSize size
);
| cid | connection tp read on |
| buffer | buffer to receive data into |
| size | size 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.
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.
if ((bytesRead = lgo_Read(cid, buffer, size)) < 0)
{
/* process error */
}
else if (bytesRead > 0)
{
/* process read data */
}
else
{
/* process other CIDs */
}