This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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