I am trying to achieve something here , I get the data from a linux system in a named pipe, the data is sporadic and does not have any determined frequency. So I have a server program in C which reads from the named pipe. But my requirement is that I have to send the data out to another program as soon I recieve the data from the client, but FREAD() function just sits on it until: a)The buffer is full and it cannot read anymore (or) b)The client closes the pipe.
The client would send every message with a delimiter of "\0", the size of the messages from the client can vary. My biggest question is how to BREAK fread after reading the message and waiting for couple of seconds and break the Fread. It just sits on the fread waiting for the data.
amountRead = fread(buffer+remaining, (size_t)1, (size_t)(BUFFER_SIZE-remaining), file);
Basically I am trying to understand if there is any way to break the FREAD after a certain amount of time (OR) based on a delimiter?