Hi,
I'm trying to write a program that reads data from a network stream.
I would like the program to read all available data in the buffer and
then process the data. I do not want the program to hang unless there
is no data in the buffer. For example if there are ten bytes available
in the buffer I would like the program to read those ten bytes and then
processed the data. If there are twenty bytes available in the buffer
I would like the program to read those twenty bytes and then process
them. My implementation looks something like this:
// Allocate the buffer
const unsigned long nBlockSize = 1000;
unsigned char pData[nBlockSize];
// Get data
while (true)
{
size_t sizeBytesRead;
sizeBytesRead = fread(pData, 1, nBlockSize, m_pFileInStream);
// Process the data