I am trying to read from a socket into a buffer until a certain character is reached using read(fd, buf, BUFFLEN).
For example, the socket will receive two lots of information separated by a blank line in one read call.
Is it possible to put the read call in a loop so it stops when it reaches this blank line, then it can read the rest of the information later if it is required?
A simple approach would be to read a single byte at a time until the previous byte and the current byte are new-line characters, as two consecutive new-line characters is a blank line:
Any unread data will have to be read at some point if newly sent data is to be read.