Hi everyone.
In this video, let's talk a little bit of time to understand what's different between the HTTP protocol
and WebSockets protocol.
So protocol is just a collection of rules we must follow to talk with order from client and server.
Okay, simple like that.
Now let's understand the protocol HTTP protocol were designed for the request and response model.
It means the HTTP protocol is clearly about one way data flow.
Okay.
Let me show you what I mean.
For example we have a client client right here, maybe JavaScript browser Postman.
It doesn't really matter.
Or the mobile phone okay.
And we have a server.
The web server.
Okay.
What is the web server?
Web server is just, uh, for example, like Apache Nginx or even Node.js.
is also the web server.
Okay.
And in order to retrieve the data, the client should send the request.
Follow the rule of HTTP for example like GET method.
And only after the client send the request, the server will have the ability to respond back to the
client.
And you can see this here.
And this here is clearly about one way data flow.
We don't have the arrows like this right.
Because the HTTP is a one way data flow
It means only the client can send a request and only the server can respond.
Okay.
The server cannot respond without client send request.
Okay.
I hope you clearly about us.
And so how about the WebSockets protocol?
WebSockets protocol is designed for true bi directional communication.
It means the server and client can be send the data.
Okay.
maybe we have a data we want send back into the server.
And server can send back it into the client.
Okay.
That's about the advantage of the WebSocket.
Now let's imagine we want to build some chat application.
Okay.
For example, we have some user interface over here with some chat.
Now how we can build that with the normal HTTP.
Okay.
We don't need to use the WebSocket right now.
Let's see how we can build a chat application using the HTTP protocol.
Well for example when I want to type some text and I will click in this button to send the text.
Over here.
So how another client can see the text over here.
Okay.
How the client.
Well in order to show the text right here, the client right here must be make a HTTP request into
the server, and after that the server will respond back to the client.
Okay.
For example, in the second time, if I type something and I click send one more time right here, clearly
the client right here doesn't have a new message because the client right here doesn't make any request.
Right.
Only
If the client right here make a new request, it will see the new message.
You can see this is the limitation of normal HTTP, right.
So right now if you don't understand this totally okay.
In the next video I will show you how we can build the chat application using the normal HTTP protocol.
I will see you in the next one.