According to the HTTP RFC (you read the protocol specs, didn't you?) the headers end (and the body begins) after two consecutive newlines are read-- which basically means at some point you'll be /sockreading an empty line. Is that hint enough?