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.
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: //127.0.0.1: 15000. In it, WS is the indication that the WebSocket protocol will be used when exchanging data. 127.0.0.1 – IP address of the computer, 15000 – the port to which connection is made. So, 127.0.0.1:15000 – 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.