fabulous Level: VB Guru

 Registered: 03-08-2002 Posts: 439
|
Re: why HTTP is a stateless or connectionless protocol?
As you know, HTTP is a text based protocol. You can transfer data and other info in such a way across the internet, that's how internet pages are transmitted.
Now consider this, AndreaVB.com has about 2618 members. If by chance, all those, or lets say, about half these members were to log on at the same time to view topics, ask questions, or post replies, and HTTP was not stateless, meaning that it kept state information and live connections to remote clients, how do you think the server would cope. Also imagine that there are a dozen other sites running of the same server, with thousands of people logging on to view information.
This would need some monster machine to be able to hold all the live references to peoples sessions. It would need massive bandwidth as well since each connection would take up a significant amount of it. Now imagine a site like Hotmail or Yahoo mail. These have millions of people signup for email addresses and are the 2 most visited sites on the internet, how do you think the servers would cope with keeping live connections to a few million clients in one go.
Something will crash.
For this reason, you connect to the server, get the info you need, and disconnect. You may still be on the net but you are not currently connected to the site. If we pull your net connection out when you are viewing this page, you will continue to see it, meaning that this info is on your computer. When I type a reply, it is happening on my computer, I can disconnect my LAN cable, reply to this message, go for lunch, come back, watch a movie, connect and then click Send Reply and the reply would go to the right page.
Why, because the state information is not kept via a live reference/connection. Some of the code sent to my machine with the HTML for rendering the page has information about the url the original message was from etc, and the page to invoke when I click the button with the parameters to pass.
When I click, the server then (this is PHP - which in some ways in similar to ASP.NET) receives a request (on some page) with certain parameters. These parameters determine how it should react. It updates the right table with the right info, and when anyone sees the page afterwards, my reply would be there.
Had there been a live reference that kept state informaton like the amount of time I have been connected, my color preferences if we had those, etc. and I had gone for a movie, lunch, a 2 hour meeting etc, this would hog the servers bandwidth and other visitors could suffer. And if HTTP was based on live connections and that connection was to somehow fail for a while, my efforts would be fruitless as I will no longer be able to reply to your post.
Dynamic websites, ASP.NET, ASP, PHP etc., keep their important state information in sessions or cookies. The sessions are on the server and if we have a million people, a million sessions, this could be a problem. This is why even sessions expire after a while.
The advantages therefore are that you don't make anyone suffer for as long as you are not using your connection, it allows for faster operation on the connnections you actually make. For instance, I am on 5 websites right now, on one cable, one internet connection. If there were live references to all these, my internet perfance would begin to go south with each additional site(and therefore connection) I visit.
I hope this brief, unplanned and unresearched reply is of some help.
____________________________
My boss is a Jewish Carpenter (Jesus Christ)

Brain Bench Certified VB.NET Developer
|