What is "websocket"

Websockets (or Websocket) is an API and protocol for bi-directional full-duplex communication over TCP sockets. The Websockets API was originally part of the standard HTML5, but was turned into a standard apart. The protocol Websockets Protocol is a standard IETF described in RFC 6455.

The Websockets API is supported from Chrome 14, Firefox 6, IE 10 (desktop and mobile), Opera 12.1 (desktop and mobile), Safari 6.0, Android 4.4, Chrome Mobile and Firefox Mobile. Some older browsers offer partial support, or may support with the help of a fallback in Flash.

Websockets support encrypted or unencrypted connections. Unencrypted connections use the "Ws://" prefix in the URL, and work through port 80. Encrypted connections use "wss://" and TLS, via port 443.

Simple example of Websockets in Javascript browser:

if ("WebSocket" in window) {
    var ws = new WebSocket("ws://echo.websocket.org/");
    ws.onopen = function() {
        console.log("WebSockets connection opened");
        ws.send("a test message");
    }
    ws.onmessage = function(e) {
        console.log("Got WebSockets message: " + e.data);
    }
    ws.onclose = function() {
        console.log("WebSockets connection closed");
    }
} else {
    // No native support
}

Useful links