WebSocket is the closest API to a network socket available in browser. This makes it probably the most flexible transport which a web application can use. That flexibility comes at price. From WebSocket perspective the message content is opaque. This means that client and server must agree on application subprotocol. WebSocket provides a simple subprotocol negotiation mechanism which helps in that task.