You might want to invest in the book "Webmaster in a Nutshell" from O'Reilly to get a better understanding of the HTTP protocol which you have to use. Web browsers hide all this stuff from you that you need to know if writing raw strings to a TCP socket.