CPS_SocRead

C Specification

#include <nitroWiFi/cps.h>
u8 *CPS_SocRead (u32 *len);

Arguments

len Data length in the receive buffer.

Return Values

Pointer to the data in the receive buffer.

Description

Performs PING/UDP/TCP reception. Returns the pointer to and length of the data in the reception buffer. When using TCP communication, len is set to 0 if the buffer is empty and disconnected. Be aware that this pointer points to the inside of rcvbuf. Executing CPS_SocRead() alone does not change the data and the data pointer. If CPS_SocRead() is executed continuously, the same data is returned continuously (the data length may increase). To proceed to the next data set, execute CPS_SocConsume(). Because the number of data sets to process can be specified with CPS_SocConsume(), in extreme case, CPS_SocConsume() can be used to segment data into bytes, which can then be processed one byte at a time using CPS_SocRead(). This is precisely how CPS_GetChar() is implemented. However, in the current implementation, CPS_SocConsume() involves the actual memmove; therefore, when rcvbuf is large, calling CPS_SocConsume() to process small segments individually is inefficient. Therefore, it may be best to prepare a sufficiently large buffer in the application, transfer data in the same segmemt size returned by CPS_SocRead(), and use tha entire data segment with CPS_SocConsume(). Does not block if the receive buffer is not empty. Blocks if it is empty.

See Also

CPS_SocConsume, CPS_SocGetChar

Revision History

10/21/2005 Initial version.