Hi!
The answers to both of your questions is simple...
Thus spake Hey You on 04/07/2007 11:51 PM:
That's because google redirects you to your localized version of
google and you did not specify the hostname in your get. You open a
socket to
www.google.ca, but you only tell it to deliver some
"index.html". If that machine hosted multiple domains (which in fact
it does), it would not know whether to send you
www.google.ca/index.html or perhaps
www.google.de/index.html.
So it informs you that it has an "/index.html" for you which it
figures might best suit your needs and that this page can be found
by issuing the following HTTP command:
GET
www.google.ca/index.html HTTP/1.0\n\n
The answer to that question is even simpler:
In HTTP/1.0, you open a socket, issue a request, get a response and
close the socket again for each and every single item you need. You
open a socket for the html-page itself, another one to request an
image specified in that page and so on. So after each request, the
socket is closed by the server.
When you specify HTTP/1.1, you have another option: pipelining. When
you request a resource via HTTP/1.1, a compliant server MAY keep the
socket open for you after it's response so that you might specify
another request without having to open a whole new socket. If the
server does this, it is the client's responsibility to close the
socket when it does not require any more data.
Try it: open up a telnet connection to
www.google.ca and issue your
request as HTTP/1.0. The socket will close immediately after the
response from the server.
Now do the same thing again but specify HTTP/1.1. This time the
socket stays open and your can issue another request (or the same
request again to keep things simple.
For further information I suggest you read rfc1945 and rfc2616
respectively.
HTH, HAND,
Phil