I am writing some code in which i need to get a line from a socket whenever the line ends in a newline or carriage return. The line shoould be stored in a buffer.
n = recv(sock, &ch, 1, 0);
if (n > 0)
{
if (ch == '\r')
{
// do stuff
}
//
}
//
I am using code like this inside a while but it is not working any clues How can i do this.
Edited: I want one line to be read from the socket and returned to be parsed. This should hap[pen for each line read.