Re: faking HTTP with a socket channel
On Mon, 11 Aug 2008, Roedy Green wrote:
If you fake HTTP by opening a socket then sending an HTTP header, does
the HTTP stuff go out in the first packet to the server, or is there
some sort of handshake first to establish the channel?
There's a handshake at the TCP level - it's called the "three-way
handshake", because it involves the client sending a connection request
packet ('SYN'), the server responding with an acceptance ('SYN+ACK'), and
the client then sending a confirmation of the acceptance ('ACK'). The ACK
packet can carry data; the other two can't. Thus, there is one round-trip
between client and server before you can start sending actual data.
There was a TCP variant, T/TCP, which let you send data in the first and
second packets too, but it never caught on, in part because there were
security concerns.
If you treat TCP as just an abstract pipe for bytes, then there's no other
handshaking before the HTTP command. The first data bytes to travel over
the TCP connection will be the 0x47, 0x45, 0x54, 0x20 at the start of the
command (assuming it's a GET, that is).
When you get your HttpConnection object, just what has happened at that
point?
Depends how you get it. If you construct it directly, nothing - the socket
isn't opened until you call connect().
tom
--
DO NOT WANT!