Introduction
In this serial of articles, I will share some knowledge I learnt recently in using WebSocket in .NET 4.5.
Protocol Overview
The WebSocket protocol was standardized by IETF as RFC 6455. We could find introductions and more information on Wikipedia and W3C.
A WebSocket connection is established by a HTTP handshake (prefixed by “ws://” or “wss://”) between the client and the server. For example (from Wikipedia), the client sends a request:
GET /mychat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Version: 13
Origin: http://example.com
Then the server sends a response to accept the connec