Book Image

Node Cookbook: Second Edition

By : David Mark Clements
Book Image

Node Cookbook: Second Edition

By: David Mark Clements

Overview of this book

Table of Contents (18 chapters)
Node Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction


HTTP was not made for the kind of real-time web applications that many developers are creating today. As a result, all sorts of workarounds have been discovered to mimic the idea of bi-directional, uninterrupted communication between servers and clients.

WebSockets don't mimic this behavior; they provide it. WebSockets work by stripping down an HTTP connection so it becomes a persistent TCP-like exchange, thus removing all the overhead and restrictions that HTTP introduces.

The HTTP connection is stripped (or rather upgraded) when both the browser and server support WebSockets. The browser discovers this by communicating with the server via GET headers, and only newer browsers (IE10+, Google Chrome 14, Safari 5, and Firefox 6) support WebSockets.

WebSockets is a new protocol. JavaScript combined with the Node platform is often versatile and low-level enough to implement protocols from scratch, or failing that, C/C++ modules can be written to handle a more obscure or revolutionary...