WebSocket()constructor returns a new
var ws = new WebSocket("ws://localhost:8080");
- The URL to which to connect; this should be the URL to which the WebSocket server will respond.
- Either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to be able to handle different types of interactions depending on the specified
protocol). If you don't specify a protocol string, an empty string is assumed.
- The port to which the connection is being attempted is being blocked.
|HTML Living Standard
The definition of 'WebSocket()' in that specification.
|Living Standard||Initial definition|