There are many blogs and discussions about websocket and HTTP, and many developers and sites strongly advocate websockets, but i still can not understand why.
for example (arguments of websocket lovers):
HTML5 Web Sockets represents the next evolution of web communications—a full-duplex, bidirectional communications channel that operates through a single socket over the Web. ( http://www.websocket.org/quantum.html )
HTTP supports streaming: request body streaming(you are using it while uploading large files) and response body streaming.
During making connection with WebSocket, client and server exchange data per frame which is 2 bytes each, compared to 8 kilo bytes of http header when you do continuous polling.
Why does that 2 bytes not include tcp and under tcp protocols overhead?
GET /about.html HTTP/1.1
Host: example.org
This is ~48 bytes http header.
http chunked encoding - http://ru.wikipedia.org/wiki/Chunked_transfer_encoding :
23
This is the data in the first chunk
1A
and this is the second one
3
con
8
sequence
0
- So, the overhead per each chunk is not big.
Also both protocol works over TCP, so all TCP issues with long-live connections are still there.
Question:
- Why is websockets protocol better?
- Why was it implemented instead of updating http protocol?
转载于:https://stackoverflow.com/questions/14703627/websockets-protocol-vs-http