2

My teacher told me today that when we request a page on a server, the server takes the request, find if it's available in the database, disconnect the user and send the requested page to the user. The server does not know if you get the packet or not. It's because the server's capacity to give service to users at a time is limited. This is why it does not keep its connection to the user. Thus, it can serve more people. He particularly gave the example of facebook and said that's why it serves millions of people and yet it doesn't get slow or hang. If that is the case then how do we get instant notification from facebook? Or how is the online friend list almost accurate always?

  • There's a difference between socket and HTTP communication. You might want to search that one up. Basically for stuff like chat, you go with Socket communication, while serving applications (like web pages), you go with HTTP/TCP as you need to just deliver and don't need to keep a connection open. – kaiser Jan 10 '16 at 16:53
  • Questions about application-layer protocols are specifically off-topic. From the help center: Off-topic If your question is about protocols above L4 in the OSI model (e.g. HTTP, FTP, etc). You may be able to ask this question on Server Fault. – Ron Maupin Jan 10 '16 at 17:34
2

Your teacher was probably over-simplifying the explanation in order to communicate that data is not being sent 24/7 from your phone (computer, pc, laptop, roku, or any other 'client') to the Server.

But the answer to your question is predicated upon understanding a few other concepts. Two of them, specifically: how HTTP Connections work, and how Push Notifications work.

HTTP has functions built in which allow multiple requests to be sent in each connection (HTTP Pipielining), as well as keeping a connection open so that additional, residual data requests can be made (HTTP Keepalives). I explain how a "regular" HTTP connection works, and how it is different when employing HTTP Keepalives and Pipelining in this thread.

As for the second part, the answer to How Push Notifications work on mobile phones is actually slightly off topic to this particular stack exchange. But it has already been answered in the Android Stack Exchange in this thread.

Read through both of those threads and you should come to an understanding of your original question. If not, please feel free to update your question, create a new question, or add comments to this one and we can help you from there.

| improve this answer | |
  • In this thread push notification of android based smartphones is explained. But what about the notification we get from facebook at the left bottom corner of our screen while browsing from a PC? Does windows have also a centralised GCM like google? Besides the thread also means that a connection to the google GCM server is 24/7 active in android smartphones, isn't it? – Farhan Fuad Jan 10 '16 at 17:46
  • @FarhanFuad That would be a function of HTTP Keepalives, explained in the other thread I linked. – Eddie Jan 10 '16 at 18:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.