Posting about web socket and real time networking
Before web socket, there is some way to network in http for real-time communication
But every method still stuck into ineffiency that its header is "overheaded" for real-time networking
- As typical tcp connection, it starts with 3 way hand shaking as follow
- porting on 80 or 443 to have connection with http
get
method,- using tcp socket in Operting System layered(?) by web socket protocol in which ensure
frame
andmessage
as data forwarding unit
here we can check out its header
GET /chat
Host: javascript.info
Origin: https://javascript.info
Connection: Upgrade [1]
Upgrade: websocket [2]
Sec-WebSocket-Key: Iv8io/9s+lYFgZWcXczP8Q== [3]
Sec-WebSocket-Version: 13 [4]
now we pay attention to [1] and [2] which means "from now on, we are networking with websocket not with http". Literally, it upgrades http networking to websocket networking.
and with [3]WebSocket-key, client and server guarantee the origin of the response and request is reliable
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: hsBlbuDTkk24srzEOTBUlZAlC2g= [1]
Once server recieve the request, it respond in http with [1]hashed result from the WebSocket-key from the previous request. if [1] doesn't match to the one in the client side, connection is not established
- hand shaking over http protocol with http header
- using http-80 or http-443 port so no any other port for web socket networking
- using
message
as a unit of data broken down toframe