Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the HTML5 Web Sockets Interface work?

I heard about the Web Sockets Interface in the HTML file specification from a relevant question here.
It sounds very promising!
I don't understand how it works does it still use the HTTP protocol and works-around it or does it work something like TCP sockets?

like image 249
Kevin Boyd Avatar asked Sep 20 '09 02:09

Kevin Boyd


1 Answers

In a way, it is both an HTTP request and a regular TCP socket.

A websocket connection is requested using a normal HTTP request over TCP. There are some headers sent that indicate to the webserver that it is a websocket that is being requested and not a normal page, but fundamentally it is just an HTTP request.

After the response is sent from the server, the connection is upgraded. That is, the TCP connection that was being used for HTTP is hijacked for a higher calling: bidirectional, realtime data transfer.

Once you have the ability to communicate bidirectionally and efficiently (which is the major win over comet), the horizons of developers is greatly increased. Suddenly, things like MMO games and realtime collaboration, that weren't possible using just web technologies, become possible.

like image 200
dan_waterworth Avatar answered Oct 29 '22 09:10

dan_waterworth