[go: nahoru, domu]

WebSocket: Difference between revisions

Content deleted Content added
m Wikilinked "polling".
Un1Gfn (talk | contribs)
m →‎top: +wikilink (indirect)
Line 17:
'''WebSocket''' is a computer [[communications protocol]], providing [[full-duplex]] communication channels over a single [[Transmission Control Protocol|TCP]] connection. The WebSocket protocol was standardized by the [[Internet Engineering Task Force|IETF]] as {{IETF RFC|6455}} in 2011, and the WebSocket [[application programming interface|API]] in [[Web IDL]] is being standardized by the [[World Wide Web Consortium|W3C]].
 
WebSocket is distinct from [[Hypertext Transfer Protocol|HTTP]]. Both protocols are located at [[layer 7]] in the [[OSI model]] and depend on TCP at layer 4. Although they are different, {{IETF RFC|6455}} states that WebSocket "is designed to work over HTTP ports 443 and 80 as well as to support HTTP proxies and intermediaries," thus making it compatible with HTTP. To achieve compatibility, the WebSocket [[Handshaking|handshake]] uses the [[HTTP/1.1 Upgrade header|HTTP Upgrade header]]<ref>{{Cite IETF |title=RFC 6455 The WebSocket Protocol |publisher = [[Internet Engineering Task Force|IETF]] |section=1.7 |sectionname=Relationship to TCP and HTTP |rfc=6455 |date=December 2011|author1=Ian Fette |author2=Alexey Melnikov}}</ref> to change from the HTTP protocol to the WebSocket protocol.
 
The WebSocket protocol enables interaction between a [[web browser]] (or other client application) and a [[web server]] with lower overhead than half-duplex alternatives such as HTTP [[Polling (computer science)|polling]], facilitating real-time data transfer from and to the server. This is made possible by providing a standardized way for the server to send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open. In this way, a two-way ongoing conversation can take place between the client and the server. The communications are usually done over TCP [[Port (computer networking)|port]] number 443 (or 80 in the case of unsecured connections), which is beneficial for environments that block non-web Internet connections using a [[Firewall (computing)|firewall]]. Similar two-way browser-server communications have been achieved in non-standardized ways using stopgap technologies such as [[Comet (programming)|Comet]] or [[Adobe Flash Player]]. <ref>{{Cite web|title=Adobe Flash Platform - Sockets|url=https://help.adobe.com/en_US/as3/dev/WSb2ba3b1aad8a27b0-181c51321220efd9d1c-8000.html|url-status=live|access-date=2021-07-28|website=help.adobe.com|quote=TCP connections require a “client” and a “server.” Flash Player can create client sockets.}}</ref>