<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>strayorange &#187; whatwg</title>
	<atom:link href="http://www.strayorange.com/blog/tag/whatwg/feed" rel="self" type="application/rss+xml" />
	<link>http://www.strayorange.com/blog</link>
	<description>The most passionate and reliable Lorem Ipsum providers in the world</description>
	<lastBuildDate>Sun, 29 Jan 2012 22:28:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HTML5 Web Sockets API reloaded</title>
		<link>http://www.strayorange.com/blog/164-html5-web-sockets-api-reloaded</link>
		<comments>http://www.strayorange.com/blog/164-html5-web-sockets-api-reloaded#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:17:59 +0000</pubDate>
		<dc:creator>CAFxX</dc:creator>
				<category><![CDATA[CAFxX]]></category>
		<category><![CDATA[dht]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[whatwg]]></category>

		<guid isPermaLink="false">http://www.strayorange.com/blog/?p=164</guid>
		<description><![CDATA[One of the most exciting upcoming features of HTML5 is the ability to open persistent bidirectional sockets to a remote host. As far as I know, one of the early proposals was about allowing web applications almost complete control over sockets, including the ability to create raw sockets and to listen for incoming connections exactly [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most exciting upcoming features of HTML5 is the ability to <a href="http://dev.w3.org/html5/websockets/">open persistent bidirectional sockets to a remote host</a>.</p>
<p>As far as I know, <a href="http://www.w3.org/TR/2008/WD-html5-20080122/#network">one of the early proposals</a> was about allowing web applications almost complete control over sockets, including the ability to create raw sockets and to listen for incoming connections exactly like a typical network daemon/server, but this proposal was later scraped because of <a href="http://cometdaily.com/2008/07/04/html5-websocket/">security implications</a>.</p>
<p>Fast forward to today and the Web Sockets API, even if still under development, are starting to get a stable shape and they will probably be implemented soon by the most forward-looking browser vendors.</p>
<p>The problem is, though, that the original proposal got crampled along the way and therefore there won&#8217;t be any means to create peer-to-peer connections between users, something that could enable <a href="http://www.strayorange.com/blog/56-a-dht-for-mozilla">all kinds of cool distributed systems</a>.</p>
<p>That is, unless someone does something: what I&#8217;m thinking about right now is a kind of wrapper/extension around the Web Sockets API that does simply a few things:</p>
<ol>
<li>allows a web application to register for incoming connections</li>
<li>opens up the required ports on the firewall/NAT</li>
<li>when a connection arrives, perform the handshaking required by the ws:// protocol and forwards a WebSocket object representing the connection to the application</li>
</ol>
<p>Talking IDL, that would mean (the WebSocket interface is the current WHATWG proposal, while WebSocketListener is my addition):</p>
<pre>[Constructor(in DOMString url, optional in DOMString protocol)]
interface WebSocket {
  readonly attribute DOMString URL;

  // ready state
  const unsigned short CONNECTING = 0;
  const unsigned short OPEN = 1;
  const unsigned short CLOSED = 2;
  readonly attribute unsigned short readyState;
  readonly attribute unsigned long bufferedAmount;

  // networking
           attribute Function onopen;
           attribute Function onmessage;
           attribute Function onclose;
  boolean send(in DOMString data);
  void close();
};

[Constructor(optional in short port, optional in DOMString protocol)]
interface WebSocketListener {
  readonly attribute short port;

  // ready state
  const unsigned short OPENING = 0;
  const unsigned short LISTENING = 1;
  const unsigned short CLOSED = 2;
  readonly attribute unsigned short readyState;

  // networking
           attribute Function onconnection;
  void close();
};</pre>
<p>Talking about the Mozilla platform, points 1 and 3 are straightforward (once the Web Sockets API has been implemented), whereas point 2 will be platform-dependent and, therefore, trickier. Nevertheless, I think that all of this can be handled (with some work) by a Firefox extension.</p>
<p>Once Firefox will gain Web Sockets support I&#8217;ll definitely try to see if it is possible to add it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strayorange.com/blog/164-html5-web-sockets-api-reloaded/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

