Reputation: 4371
What is happening to a TCP connection after
an end of an HTTP session?
for example, after loading a static webpage from a webserver
Thanks
Upvotes: 0
Views: 1296
Reputation: 13690
You can have several HTTP request in one TCP connection. So it if you refer a HTTP session as a set of HTTP requests/responses, the TCP connection will be closed.
At TCP level the closing side sends a packet with the FIN flag set, the other side acknowledges this with ACK, and immediately or eventually does his own FIN, which the first acknowledges again with ACK. It's also possible that the connection is abandonded with the RST instead of FIN flag. The port that sent the first FIN goes into the TIME_WAIT state. This is used to reject packets that arrive subsequently, that would otherwise be misinterpreted as packets of a new connection. After the timeout the port goes from the TIME_WAIT state to the CLOSED state.
Edit: Normal termination is indicated by the FIN flag.
Upvotes: 0
Reputation: 22279
A HTTP session usually refers to the server is keeping an association to a specific user and could potentially be of any length (using, for instance, cookies as association tokens).
A HTTP session therefore usually contains multiple TCP sessions. For non persistent HTTP connections, every request has its own TCP session (and is closed after). For persistent HTTP connections on the other hand, multiple HTTP resources could be fetched wihtin a TCP session and either side will close it upon a reached timeout threshold on either side.
Wikipedia article on Persistent HTTP connections (Keep-Alive: true)
Upvotes: 1