This function retreives data from the connection's incoming buffer.
rrid_t rascal_read( rrid_t conn, void *buffer, unsigned int *buffer_size );
Parameters.
conn
Handle of the connection that the data must be retreived from. If the handle does not correspond to a valid data oriented connection, an error is reported.
buffer
, buffer_size
Location and dimension of the buffer that receives the data. Before calling the function, buffer_size
must be set to the size of the buffer, in bytes. When the function returns with success, buffer_size
is updated with the number of bytes actually retreived; this value never exceeds the original buffer size.
Return value.
On success, the function returns REC_SUCCESS
, otherwise an error code is returned. Error code REC_NO_DATA means that the buffer was empty and to data could be retreived (whether this is an error or not is up to the application).
Remarks.
When reading from a stream-oriented connection, the whole incoming buffer can be retreived with one call. If conn
corresponds to a datagram connection, only one full datagram will be retreived with each call, no matter how large the buffer is. When no more datagrams are available, the function returns REC_NO_DATA
.