Originally Posted by
Sebastiani
you need to be check the return value of recv. if it does return an error, the data is basically useless to your program *anyway* - it would probably be a good idea to throw an exception at that point (possibly unpacking errno into some user-friendly message as well). another thing I noticed is that you treating '\n' as your eol. remember that HTTP uses '\r\n' to delineate lines. also, single-transfer connections are typically shutdown after reading/writing the entire message. finally, reading a single byte from a TCP connection is horribly inefficient. I would recommend reading the entire message into a buffer before parsing each line out.