What is websocket? Finally we have the answer to your question
Welcome to the eHorus blog, that extensive encyclopedia of computer concepts. Today we are going to deal with the popular question “what is websocket?”. You probably won’t get it in the Saturday night Summer Trivia game with your camping buddies or on a tv show.
What is Websocket?
Many of you will have heard about this new component in HTML5, but, even so, you don’t understand how to work with websockets. Websocket is an API that allows us to carry out bidirectional and open communication between two devices; in this precise case, between a client and a server.
Let’s give an example: Pepín is a very nice middle-aged man who organizes meetings of “Friends of 600”. Well, let’s imagine that Pepín accesses a website. When Pepín accesses a website, what really happens is that two computers are talking, they have a chat. One of the computers is Pepín’s and the other is the server.
“The client computer”, Pepín’s computer, makes a communication request on a “server computer”. In this case the communication request begins with a greeting. Pepin’s computer says something like “Hello” to the server computer. The server computer responds, “Hello, you too.” For the record, it’s a figurative conversation, don’t get involved, nobody here says “Hello” literally. Pepín’s pc continues: “Can I send you a file?” For example, if Pepin wanted to send a file. The server will say, “What kind of file?” “A jpg file” will tell you Pepin’s computer. “How much does this jpg file weigh?”, and so on… then Pepín’s computer will answer him, etc…
The server computer will always answer you depending on what has been predetermined in it before for an exchange of this type of files.
This is what usually happens when we work with or interact with a static page, those of all life, a simple page. The conversation is closed and simplified. The bad thing is that every time Pepin comes to your page to get new information he will have to start again with this conversation. Why? Because there is no open communication between the two or at least it is not kept open.
Both the client and the server forget that this conversation has ever occurred at the time the connection is closed. Therefore, every time you go back in you have to start with the “hello” to the server, show them your intentions, what you want, how you want it, and then say goodbye. And I’m sorry, no matter how much you esteem your servant, when it’s all over he won’t remember you, nor when you come back to him for new material. “Oblivion is the only revenge and the only forgiveness.” -J.L. Borges-
Don’t take it too personally, Pepin, it’s all programmed that way. Yours is a single-petition, momentary and perishable connection, and the protocol is designed to serve a vast number of people. You can’t just maintain deep connections for free.
What is websocket, then? Well, with websocket, this communication we’ve been talking about is kept open. A websocket is created and at the moment it is opened an open biderectional communication can be made. This means that the server can talk to the client and the client can talk to the server. The ultimate goal of websockets is to send information (or communication between client and server) in real time. A socket is a two-way communication protocol and a websocket is the same, only it works within another directional protocol called HTTP.
As I say, the purpose of websocket is to create bidirectional and lasting connections between a client and a server. We create the connection, client and server, we consider how to communicate using the same scheme as HTTP, only keeping the port open and deciding to send messages in real time.
In this way, the server will be able to send Pepín, or any of his esteemed clients, any message at any time and they will receive it immediately. The same thing would happen to the opposite. We will be able to create a message from our computer and we will be able to send it without having to start from scratch with a new connection or with the happy conversation. It’ll be open and it’ll recognize us.
And now you are more or less ready to answer the fearsome question. I don’t mean “do you still love me?”, but “what is Websocket?” But… do you already know eHorus?
Ehorus is a remote computer management system (remote desktop software) that can help you with many tasks.
Do you want to know what eHorus can do for you? You can see much more by going to: https://ehorus.com/
Or you can send us any question you may have about eHorus. You can do so using the contact form found right here: https://ehorus.com/contact-us-remote-management-software/
Our eHorus team will be happy to assist you!