HTTP is a blocking, synchronous protocol. This means that the client must wait for a response from the server before it can continue. The server blocks clients from performing any actions; because the customer must wait for a response. After the browser receives the response, the connection is discarded, and then another connection is opened, and the process repeats until all elements of the page are displayed.
This is the network state and nature of the HTTP protocol.
Ajax just creates a background process that does what the browser would do - it still blocks, but the end effect is that the user can still interact with the client. The browser displays something and is not effectively blocked.
A real-time website allows you to have an open socket that is not blocking, asynchronous. Asynchronous means that you do not need to wait for an answer to return - the client is not blocked. You can send several requests, and then, when the server is done with them, it will respond back. You do not need to "wait."
Many of the things you use every day are asynchronous:
- Any chat application - for example, IRC, facebook messenger, whatapp, etc.
- A phone conversation with a really chatty friend (usually you wait to hear another person’s answer, but some people just talk and talk ...).
- Everything that is broadcast, such as YouTube.
Just think about it: “one side does not have to wait to start the transfer again.”
On the network, it is activated in real time, bypassing HTTP restrictions. Here WebSockets and Server Sent Events (SES) .
The first is the standard way to open a full-duplex (i.e. you can send and receive at the same time) channel over TCP.
The second (SES) is still standardized as part of HTML5, but allows the server to send notifications to the client, not the client, which should poll the server for events. Therefore, instead of sending a request to check for updates, the server will inform you when the update will be available - for example, "don’t call me, I’ll call you."