protocol
Summary
Indicates the name of the sub-protocol the server selected.
Property of apis/websocket/WebSocketapis/websocket/WebSocket
Syntax
Note: This property is read-only.
var result = element.protocol;
Return Value
Returns an object of type StringString
This will be one of the strings specified in the protocol parameter when creating the WebSocket object.
Notes
Protocol negotiation is part of the WebSocket connection handshake. The protocol value is not set until the connection is established. If the client specifies one or more protocols, the server returns one or none of the protocols during the protocol negotiation in the handshake. After the connection is established, then the protocol value is either empty or set to the protocol that was accepted.
Related specifications
- W3C WebSocket Specification
- W3C Candidate Recommendation
Attributions
Mozilla Developer Network : Article
Microsoft Developer Network: Windows Internet Explorer API reference Article