I'm now preparing SCEA exam part-1. After I did serveral mock tests, I'm confused with the question "Is HTTP protocol connection-less or connection-based?". Some mock tests say it is connection-less, while the other say it is connection-based. Anybody has some idea on this question? Thanks
HTTP 1.0 uses 'Tear Down'.. the client opens and closes a socket connection for each request so is connectionless. HTTP 1.1 uses 'keep alive'.. the client holds the socket open over multiple requests. However, this is still regarded as connectionless as it is acceptable for the client or server to drop the connection at any time and the connection will be re-established again later.
I believe that HTTP is a connection-based but stateless protocol. It is connection based because it rides on top of TCP/IP which is a connection based protocol. Now as others have pointed out the connection is made and then closed after each request in HTTP1.0 (that still doesn't make it connection less) In HTTP1.1, there is the concept of a durable connection (using the same connection across multiple HTTP requests.) Since the server does not inherently care if two requests came from the same client, it is a stateless protocol. We can add state by using many techniques, some of which include HTTPS (secure and stateful), or by using the HTTP Session Object and rewriting the session key with every URL / cookies e.t.c.
Sanjay Raghavan<br />SCJP2, SCEA-J2EE<br />Moderator - <a href="http://groups.yahoo.com/group/scea_prep" target="_blank" rel="nofollow">SCEA PREP</a><br />Co-Author - <a href="http://www.whizlabs.com/scea/scea.html" target="_blank" rel="nofollow">SCEA@Whiz</a><br /><i>Where did you sip your Java Today?</i>
I agree with all that is said here. However there are couple of possibilities by mixing and matching connection and connectionless layers. I think there are lot of articles and guidelines in selecting the match according to application criteria. So coming from that angle http is a connecionless layer built on top of a connection oriented layer with the notion of servicing many clients. Similary there could be connection oriented layer somehow maintaining connection information over connectionless layer. So categorizing a session level layer as connection or connectionless just based on the transport layer may not be right. I think I have added some more confusion and the question that is http connection oriented or connectionless still remains ambiguous.
subject: HTTP protocol: Connection-less or Connection-based?