Over the holidays, the Cheyenne web server that is used in Syllable Server got a WebSocket framework. Cheyenne’s author Nenad Rakocevic implemented WebSocket support in just a day on top of the UniServe universal network I/O subsystem that underpins Cheyenne. In a few more days, he designed an original WebSocket framework supporting persistent connections in an efficient manner, extending the regular Cheyenne framework for the typical HTTP stateless request/response communication.
WebSocket is a part of the upcoming HTML5 web standards. It allows a web browser and a web server to have a persistent, two-way full-duplex connection using just one TCP connection. It does this by starting a regular HTTP connection and then effectively renegotiating it into its more flexible underlying TCP connection. This gives it good chances to traverse firewalls, effectively giving us back the full power of the Internet.
In this way, it is an evolution and replacement of Comet, which is a collection of hacks to use Ajax to simulate persistent HTTP connections. WebSocket improves over Comet by being standardised, much cleaner and more scalable. It does, however, require explicit support by both the server and the client. Currently, only Chrome4 has WebSocket support. It is planned for Firefox and Safari. The latter means the WebKit rendering engine and that means WebSocket can be ported to Syllable’s browser Webster.
The Syllable project intends to use this framework in its web infrastructure. The Cheyenne WebSocket framework is available in its SVN version. A WebSocket echo demo program is available here.
I hope websockets and new html5 technologies make the code cleaner. Now with hundreds of plugins and the mixing languages of ajax, to see a web code is too uncomfortable.