Que es WebSocket y para que sirve

WebSocket es una tecnología que proporciona un canal de comunicación bidireccional y full-duplex sobre un único socket TCP. Está diseñada para ser implementada en navegadores y servidores web, pero puede utilizarse por cualquier aplicación cliente/servidor.

The WebSocket specification—developed as part of the HTML5 initiative—introduced the WebSocket JavaScript interface, which defines a full-duplex single socket connection over which messages can be sent between client and server.

The WebSocket standard simplifies much of the complexity around bi-directional web communication and connection management.

One of the more unique features WebSockets provide is its ability to traverse firewalls and proxies, a problem area for many applications.

Comet-style applications typically employ long-polling as a rudimentary line of defense against firewalls and proxies.

The technique is effective, but is not well suited for applications that have sub-500 millisecond latency or high throughput requirements.

Plugin-based technologies such as Adobe Flash, also provide some level of socket support, but have long been burdened with the very proxy and firewall traversal problems that WebSockets now resolve.

A WebSocket detects the presence of a proxy server and automatically sets up a tunnel to pass through the proxy.

The tunnel is established by issuing an HTTP CONNECT statement to the proxy server, which requests for the proxy server to open a TCP/IP connection to a specific host and port.

Once the tunnel is set up, communication can flow unimpeded through the proxy.

Since HTTP/S works in a similar fashion, secure WebSockets over SSL can leverage the same HTTP CONNECT technique.

Note that WebSockets are just beginning to be supported by modern browsers (Chrome now supports WebSockets natively).

However, backward-compatible implementations that enable today's browsers to take advantage of this emerging technology are available.

En el lado del cliente, WebSocket está ya implementado en Mozilla Firefox 8, Google Chrome 4 y Safari 5, así como la versión móvil de Safari en el iOS 4.2.1

Casiano Rodriguez León 2015-01-07