1. Computing

Discuss in my forum

HTML5 WebSockets

What is the WebSockets API

By , About.com Guide

Web pages are delivered from web servers using a request/response system of HTTP. When a user agent opens a web page, that page is requested from the server, all the elements are downloaded and displayed, and then nothing happens again until an event fires, such as a click. This interaction means that web pages can be very slow, or appear slow. There is also a lot of latency.

WebSockets Speed Things Up

An HTML5 WebSocket allows the user agent to connect with the server with bi-directional, full-duplex communication. This reduces network communication and latency. It also reduces the burden on the server, so more concurrent connections can happen at once.

The WebSockets API was originally part of the HTML5 specification, but was separated into its own specification to stay more focused. The WebSockets API specification is currently in a draft status.

WebSockets can be used in any web application, but are best used when you need low latency or a nearly realtime connection between the client and server. This would include multi-player games, online chat, tickers, streaming, and so on.

WebSockets Browser Support

The WebSockets API has support in Chrome 4 and Safari 5. It also is supported in Opera 11 and Firefox 4, but in both of these browsers it is disabled because of security concerns. It is also supported in the mobile iOS Safari, but it is not supported in Android, Opera Mini, or Opera Mobile.

WebSockets Examples

If you are using either Safari or Chrome you can check out these examples to see how WebSockets work.

©2013 About.com. All rights reserved.