Home computickets What is the difference between Socket'om and WebSocket'om?

What is the difference between Socket’om and WebSocket’om?




I realized that the socket is roughly speaking the nest interface (as the parameters of the IP of the computer and port), which creates a program through which another computer can be connected to prescribing the same address and port. And here the web sockets are called. What is the difference between them?

Answer 1, Authority 100%

Web socket is just a wrapper around ordinary TCP sockets (although I suspect that theoretically can be around anything, which might look like a socket). The difference from ordinary sockets is that the exchange protocol is standardized (but there are several standards) and the exchange is very similar to the usual HTTP. Also, browsers are able to make it out of the box (not all truth). And also websites help with security and other buns.

Why do you need it? Yes, everything is simple. People in the modern web want chats, puff of note, and the usual HTTP unidirectional and have to constantly knock on the server. Ordinary sockets in JavaScript add is difficult to add (about why – default), so made a beautiful wrapper.

Answer 2, Authority 236%

socket is really Program Interface . This is an abstract concept that, in most cases, is used to communicate programs on the network (but not only).

Websocket is Protocol (any pre-agreed order) data exchange (such as http, ftp, ssl, etc.). This protocol comes over (transmitted by) TCP protocol.

socket and WebSocket is different concepts in principle. When working on the WebSocket protocol, you will use conventional sockets to connect. As well as when working with other protocols, sockets will be used (and to work with HTTP, with FTP et al.).

For example, consider the string of the species – WS: // 15000. In it, WS is the indication that the WebSocket protocol will be used when exchanging data. – IP address of the computer, 15000 – the port to which connection is made. So, – this couple, if it can be shattered, and is a socket.

WebSocket protocol was created in order to maintain long-term inseparable connections between the browser (which is the client) and the Web site (which is the server).

WebSocket protocol is not similar to HTTP. The only thing that he reminds HTTP is only one of the first connection request (so-called handshake / handshake). This was done, because initially the protocol is designed to work in the browser and it was necessary to determine the ability to support it. After the connection is set, nothing like the HTTP protocol in the WebSocket protocol is even close.

Websocket protocol itself does not guarantee any security for the transmitted data. The minimum coding that it provides is a banal srser (XOR). At the same time, a srser mask is transmitted along with the message. And it is intended for this srser to transmit data through a proxy server that do not know anything about WebSocket protocol. This is not the protection of your data is to protect the proxy server. And in the opposite direction (from the site to the browser), the data is not encoded by a sorce, due to the lack of need.

It is the absence of any beams in the WebSocket protocol and gives it a possibility of fast work.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions